stringstream 未在此范围内声明

发布于 2024-09-06 03:49:54 字数 616 浏览 1 评论 0原文

我在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

屌丝范 2024-09-13 03:49:54

如果包含 #include ,则还必须通过以下方式引用该类:

std::stringstream 或在之前声明 using namespace std;使用它。

如果您发布更多信息,我们可以提供更详细的帮助。

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.

我最亲爱的 2024-09-13 03:49:54

这段代码在 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
}

唯一的区别是我删除了 #include "SymbolTable.cpp",并添加了 label43

显然,如果它对您不起作用,则问题出在您省略的某些代码中。 //some code here 部分或 SymbolTable.cpp

当然,您包含 cpp 文件似乎也非常可疑。这很可能是一个错误。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文