Netbeans 7.2 shows “Unable to resolve identifier”

2020-01-26 02:17发布

问题:

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?

回答1:

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

Unresolved Identifier

If the source of the .cpp file looks like this

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

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

Set the include path correct.

I hope that can help you.



回答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.



回答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:

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:

  2. So I clicked EncodingConvert 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:

    I hope it saves some time for someone else too.



回答4:

I recently had this error with netbeans 8.0.2 on OS X, and couldn't find an answer for what to do.

I solved the problem by uninstalling the C/C++ plug-in, when I reopened netbeans it prompted me to 'fix code assistance..'.

Clicking the prompt and letting it run the problem was fixed.



回答5:

I am using NetBeans 8.1 and the same problem popped up when I started a new C++ project. It solved itself after running the project through the debugger.



回答6:

We develop our code on one computer and compile on another. I was getting these distracting markups until I "set Build Host" to the remote machine (in the right-click menu for the project).

I'm still not sure what the problem on the development computer was, since the unresolved identifiers were things from the standard library (size_t, std::vector etc) and the answers here didn't seem to help.



回答7:

I always have to reinstall MPLAB X when this happens. Other things work from time to time, but that always works.



回答8:

I often have this error, and as others mentioned, usually I add space character, save the file, remove the space character... and all identifiers are solved.

This time it did not work. My project, which I compiled thousand times, and it always worked, suddenly crashed MPLAB X IDE v3.35 (Mac OSX, but likely it doesn't matter), while typing text. After this I have in one file only and for one structure only, all identifiers unresolved.

Structure in profile.h file was:

typedef struct
{
    int state;                      ///< state machine current state
    int enabled;                    ///< machine can be ENABLED or DISABLED
    int flag;                       ///< to initiate profile execution
   ... many variables here ...
    unsigned long timestamp;        ///< variable used for local timing
} profile_struct;

In my profile.c file any variables from this structure became unresolved, but project compiled and worked fine.

After a frustrating hour of trying, this solved my problem: Erased the whole MPLABX cache directory.

In my case, it is located at:

/Users/USER_NAME/Library/Caches/mplab_ide/dev/v3.35/var

(need to erase the whole 'var' directory; and of course replace the USER_NAME with your user name)

Note, that the 'Library' is a hidden directory, but you can still access it if you enable viewing hidden files, or go straight to it via terminal.

Lastly, on your computer it might be somewhere else. I found mine by watching, which files were modified on my computer in the last 2 minutes, by using the terminal command:

/usr/bin/find /Users/USER_NAME/ -mmin -2 –ls


回答9:

Mine worked once i renamed my main.c to main.cpp.

Based on the file extension, the behavior of Netbeans Code Assistance changes



回答10:

try Click by Right button the file, Properties->General->Exclude from code assistance (disable)