Netbeans 7.2 shows "Unable to resolve identifier" , although build is successful

I'm using the Netbeans IDE 7.2 with C/C++ plugin (last version 1.18.1.1) and if I build my project everything is fine but the IDE show me errors (e.g. unable to resolve identifier ...)

Anyone else have this bug and how can I solve it?


Solution 1:

Here's an excerpt from my answer to another question.

Unresolved Identifier

If the source of the .cpp file looks like this

enter image description here

Click with the right mouse button on your project.
Check C/C++ Code As...
Run Reparse Project.

enter image description here

If that is not enough.
Go to Project Properties
Fill in the Include input field as described.

enter image description here

Set the include path correct.

I hope that can help you.

Solution 2:

i had the same problem, but i recognized it appears after i changed properties-> c++ compiler -> Compilation Line -> additional options to -std=c++11. if change the settings to default the error "unable to resolve identifier" disapears.

Solution 3:

TL;DR

UTF-8 WITH BOM can cause problems too.

PROBLEM

I just had the same problem, and I tried lots of possible solutions, but none of them worked, until I found out the source of the problem, which was a bit funny. I know this question has already been answered, but I write down my solution, maybe it will solve the problem of someone else suffering from the same problem.

For example, I got "Unable to resolve identifier Vector" when defining struct Vector, while it was correct:

Unable to resolve identifier Vector

I got many errors similar to this when declaring/defining functions, etc. Additionally, my code assistance didn't work because of the amount of errors.

SOLUTION

  1. I opened the .cpp file in Notepad++, and saw the file was encoded in regular UTF-8, which means that the file begins with the byte order mark (BOM) character:

    Notepad++ - file encoded in UTF-8 WITH BOM

  2. So I clicked EncodingConvert to UTF-8 without BOM:

    Notepad++: Encoding - Convert to UTF-8 without BOM

    Note: do NOT just switch to "Encode in UTF-8 without BOM", because it can mess up some special characters (e.g. characters containing accents, etc.). So convert it.

  3. Save

  4. Problem gone: no errors reported in NetBeans anymore:

    NetBeans - no errors reported anymore, problem solved

    I hope it saves some time for someone else too.