Search code examples
c++ceclipse-cdt

Generic solution to Eclipse CDT's symbol 'X' could not be resolved?


I have a project with C++ and C files. The code compiles and runs correctly, but I need to get rid of the following error:

Symbol 'ERANGE' could not be resolved

I was able to reproduce it with these two files (latest x64 Elipse Juno on Ubuntu):

main.h:

#ifndef MAIN_H_
#define MAIN_H_

extern "C" {
#include <errno.h>
}

#endif /* MAIN_H_ */

main.cpp:

#include <cerrno>
#include <cassert>
#include "main.h"

int main(int argc, char * argv[]) {
    assert(errno != ERANGE); // <-- CDT ERROR here
    return 0; }

Doing Open Declaration on ERANGE correctly takes me to /usr/include/asm-generic/errno-base.h file.

The following workarounds to similar issues DID NOT work:

  • Setting Indexer -> Use active build configuration
  • Manually adding the ERANGE symbol to project Paths and Symbols
  • Adding main.cpp to Preferences -> C/C++ -> Code Analysis -> Symbol is not resolved -> Customize Selected... -> Scope -> Exclusion patterns

The only solution that will work is disabling the Symbol is not resolved error completely, but that will cause me to miss real issues.

Edit: CDT bug filed https://bugs.eclipse.org/bugs/show_bug.cgi?id=404017


Solution

  • Looks like a bug in the Eclipse CDT code analysis tool (codan). I recommend submitting a bug report here.