简体   繁体   中英

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 (eg unable to resolve identifier ...)

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

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.

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.

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 :

    Notepad++ - 以 UTF-8 编码的文件和 BOM

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

    Notepad++:编码 - 转换为 UTF-8 而不使用 BOM

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

  3. Save

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

    NetBeans - 不再报告错误,问题已解决

    I hope it saves some time for someone else too.

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.

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.

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.

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

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

Three ways to solve the issue of "unable to resolve identifier" error in Netbeans 12.

  1. Right click on "Project". Select "Code Assistance". Clean C/C++ cache. Restart IDE.
  2. 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.
  3. 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.

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++;}

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

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

尝试按右键单击文件,属性->常规->从代码帮助中排除(禁用)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM