Netbeans 7.2 shows "Unable to resolve identifier" , although build is successful
C++LinuxNetbeansNetbeans 7C++ Problem Overview
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?
C++ Solutions
Solution 1 - C++
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.
Solution 2 - C++
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 - C++
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
-
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: -
So I clicked 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.
-
Save
-
Problem gone: no errors reported in NetBeans anymore:
I hope it saves some time for someone else too.
Solution 4 - C++
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.
Solution 5 - C++
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.
Solution 6 - C++
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.
Solution 7 - C++
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
Solution 8 - C++
I always have to reinstall MPLAB X when this happens. Other things work from time to time, but that always works.
Solution 9 - C++
Three ways to solve the issue of "unable to resolve identifier" error in Netbeans 12.
- Right click on "Project". Select "Code Assistance". Clean C/C++ cache. Restart IDE.
- Right click "Project properties"---> go to build--> under C/c++ compiler, set both your C and C++ compiler to the same standard, on every C/C++ project.
- Under tools--> options--> C/C++-->code assistance, change:__cplusplus=199711L to:__cplusplus=201402L for C++14 or to __cplusplus=201103L for C++11
I realised while resolving my own problem, the proper/aligned enclosing braces could cause the above error. Make sure your braces are balanced and aligned.
Solution 10 - C++
I had the same problem after copying a code having NULL comparison:
while (str1[i] != ’\0’) {
out[i] = str1[i];
i++;}
After searching a lot , it turned out the weird ’ quotation used is the problem , I changed it to the normal ' and everything worked normal
while (str1[i] != '\0') {
out[i] = str1[i];
i++;}
Solution 11 - C++
Mine worked once i renamed my main.c to main.cpp.
Based on the file extension, the behavior of Netbeans Code Assistance changes
Solution 12 - C++
try Click by Right button the file, Properties->General->Exclude from code assistance (disable)