Originally Posted by
laserlight
Without any more evidence, I daresay that you have a bug in your code, possibly one that results in undefined behaviour, e.g., you access an array out of bounds. This bug then shows up when you use a stringstream.
I've stripped the code down to almost nothing.... here is the entire project.
header file
Code:
#include <inttypes.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <sys/stat.h> //file statistics
using namespace std;
enum MiStatus{
MIS_OK
, MIS_CFG_FAILED
, MIS_CONNECTION_FAILED
, MIS_OPEN_FAILED
, MIS_SEND_FAILED
, MIS_INVALID_ARGS
};
extern "C"{
// send message to default queue manager
MiStatus msg_send_q(
const char *destination,
const char *message,
uint32_t messageLength,
uint32_t persistence);
}
This code runs sucessfuly
Code:
#include <unistd.h>
#include <string.h>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <cmqc.h>
#include <cmqxc.h>
#include "swmq.h"
#include <inttypes.h>
MiStatus msg_send_q(
const char *destination,
const char *message,
uint32_t messageLength,
uint32_t persistence)
{
string destType = "QUEUE";
MiStatus rv;
return rv;
}
This code fails
Code:
#include <unistd.h>
#include <string.h>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <cmqc.h>
#include <cmqxc.h>
#include "swmq.h"
#include <inttypes.h>
MiStatus msg_send_q(
const char *destination,
const char *message,
uint32_t messageLength,
uint32_t persistence)
{
string destType = "QUEUE";
MiStatus rv;
stringstream test;
return rv;
}