stringstream 未在此范围内声明
我在使用 stringstream 时遇到问题。我的 Visual Studio 和 linux g++ 都不能理解 stingstream。我已经添加了 sstream 但它没有解决任何问题。我以前用过它,真的不知道现在怎么样了?
#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 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果包含
#include
,则还必须通过以下方式引用该类:std::stringstream
或在之前声明using namespace std;
使用它。如果您发布更多信息,我们可以提供更详细的帮助。
If you include
#include <sstream>
then you must also reference the class by:std::stringstream
or declareusing namespace std;
before using it.If you post more information we could provide more detailed help.
这段代码在 G++ 下编译得很好:
唯一的区别是我删除了
#include "SymbolTable.cpp"
,并添加了label43
。显然,如果它对您不起作用,则问题出在您省略的某些代码中。
//some code here
部分或SymbolTable.cpp
当然,您包含 cpp 文件似乎也非常可疑。这很可能是一个错误。
This code compiles fine for me under G++:
The only difference is that I removed
#include "SymbolTable.cpp"
, and added alabel43
.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 inSymbolTable.cpp
Of course, it also seems very suspicious that you're including a cpp file. That is most likely an error.