views:

59

answers:

2

I'm having problem with stringstream.my visual studio nor linux g++ can understand stingstream. I've added sstream but it does'nt solve anything. I've worked with it before and really don't know what's up with it now?

#include <sstream>
#include <stdlib.h>
#include "SymbolTable.cpp"
#include "setjmp.h"
using namespace std;
jmp_buf *bfj;
int TOP , SP=3 ;
struct types{int int_val;float float_val;char char_val;bool bool_val;};

types DS[6400];
int main(){
...//some code here
label38 : stringstream s;
label39 : bfj = (jmp_buf *)"label65";
label40 : longjmp(*bfj,1);;
label41 : goto label43;
label42 : TOP=SP;
//some code here
}

I'm writing a compiler so the code is the output,that's why it may seams a bit odd.

+2  A: 

If you include #include <sstream> then you must also reference the class by:

std::stringstream or declare using namespace std; before using it.

If you post more information we could provide more detailed help.

Amardeep
namespace std helps it.thanks!
angela
@angela: you already had that in the code snippet you posted though.
jalf
+1  A: 

This code compiles fine for me under G++:

#include <sstream>
#include <stdlib.h>
#include "setjmp.h"
using namespace std;
jmp_buf *bfj;
int TOP , SP=3 ;
struct types{int int_val;float float_val;char char_val;bool bool_val;};

types DS[6400];
int main(){
label38 : stringstream s;
label39 : bfj = (jmp_buf *)"label65";
label40 : longjmp(*bfj,1);;
label41 : goto label43;
label42 : TOP=SP;
label43 : (void)0;
//some code here
}

The only difference is that I removed #include "SymbolTable.cpp", and added a label43.

So apparently, if it doesn't work for you, the problem is in some of the code you omitted. The //some code here parts or in SymbolTable.cpp

Of course, it also seems very suspicious that you're including a cpp file. That is most likely an error.

jalf