Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stringstream was not declared in this scope

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.

like image 579
angela Avatar asked Jun 21 '10 17:06

angela


2 Answers

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.

like image 91
Amardeep AC9MF Avatar answered Oct 13 '22 00:10

Amardeep AC9MF


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.

like image 23
jalf Avatar answered Oct 13 '22 01:10

jalf