错误的“无法解析标识符"在 Netbeans 中

2021-12-26 00:00:00 netbeans c++ c++11 netbeans-8

我的程序编译良好,但 Netbeans 告诉我无法解析标识符 to_string."

My program compiles fine, but Netbeans tells me "Unable to resolve identifier to_string."

我尝试了中的所有内容Netbeans 7.2 显示无法解析标识符",尽管构建成功",我在代码辅助选项中将C++ 标准"设置为C++11".

I tried everything in "Netbeans 7.2 shows "Unable to resolve identifier" , although build is successful" and I set the "C++ standard" to "C++11" in the code assistance options.

这是迄今为止唯一给出此问题的函数.然而,这也是我使用的第一个 C++11 特性,这让我相信它与 Netbeans 不理解我使用 C++11 有关系,尽管我在代码帮助菜单中明确指定了它.

This is the only function giving this problem so far. It is however also the first C++11 feature I am using, which leads me to believe it has something to do with Netbeans not understanding that I am using C++11, although I specify it explicitly in the code assistance menu.

最小示例:

#include <string>
int main() {
    std::to_string(1);
}

在使用 nullptr

我突然意识到有必要提及我不使用生成的 Makefile,而是使用 SCons.

I suddenly realized it might be important to mention that I do not use a generated Makefile, but SCons.

推荐答案

我知道这个问题已经有七个月的历史了,但由于它是谷歌搜索的第二个结果,我会告诉我想出的答案.至少对于 Netbeans.转到您的项目属性并确保将C 编译器"->C 标准"设置为 C11,并将C++ 编译器"->C++ 标准"设置为 C++11.你必须设置 BOTH 否则它仍然会给出错误的错误!

I know this question is seven months old but since it came up as the second result to a google search I'll tell the answer I came up with. For Netbeans at least. Go to your project properties and make sure you have you "C Compiler"->"C Standard" set to C11, and your "C++ compiler"->"C++ Standard" set to C++11. You have to set BOTH or it will still give false errors!

相关文章