Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erroneous "Unable to resolve identifier" in Netbeans

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

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.

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.

Minimal example:

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

EDIT: the same problem arises where using nullptr

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

like image 286
Oebele Avatar asked Jun 06 '15 18:06

Oebele


3 Answers

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!

like image 122
Robert Reinhart Avatar answered Oct 15 '22 18:10

Robert Reinhart


This will solve the problem:

  1. Right click on "Project".
  2. Select "Code Assistance".
  3. Clean C/C++ cache.
  4. Restart IDE.
like image 4
Shreejit Paul Avatar answered Oct 15 '22 18:10

Shreejit Paul


Autocomplete and sometimes even syntax highlighting are always faulty with C++. The more you go in depth with C++ and C++11, the more Eclipse and Netbeans will start underlining everything with a red wavy line. Some of my (correct and perfectly compiling) programs are a huge red wavy line. I suggest you disable error markers altogether and you keep autocomplete, but in many cases it just won't work and you have to make the best of it.

like image 2
gd1 Avatar answered Oct 15 '22 19:10

gd1