Indexer can`t resolve symbols in C files, but resolve them in C++ files [message #1713343] |
Tue, 03 November 2015 14:06  |
Eclipse User |
|
|
|
 Hi!
I have a project with mixed C and C++ code. When I started use Mars, I found that some symbols were not resolved in C files. These are type definitions and variables defined in included files. Functions are resolved correctly (see the screenshorts attached).
But if I change the file name extencion frm ".c" to ".cpp", the problem disappears.
All include paths are configured in the project properties. I tried to reindex and even deleted all .pdom files from the project, but nothing has helped.
How can I force it to index C files correctly?
Thanks for any suggestions

Attachment: c_file.png
(Size: 94.95KB, Downloaded 9131 times)
Attachment: cpp_file.png
(Size: 94.86KB, Downloaded 9433 times)
|
|
|
Re: Indexer can`t resolve symbols in C files, but resolve them in C++ files [message #1713356 is a reply to message #1713343] |
Tue, 03 November 2015 14:47   |
Eclipse User |
|
|
|
You said all include paths are configured in the project properties but are they? If you look at Project ==> Properties ==> C/C++ General ==> Preprocessor Include Paths, Macros, etc. you will see there are selections for different languages in the Entries tab. Are the paths available to c++ also available to c? If not, add the path to the header containing the definition of INT8U to the set of c paths then rebuild the index.
If that doesn't work then what's the actual error message? It would have been nice if you had selected the Problems view in you snapshots instead of the Console view.
|
|
|
Re: Indexer can`t resolve symbols in C files, but resolve them in C++ files [message #1713381 is a reply to message #1713356] |
Tue, 03 November 2015 16:44   |
Eclipse User |
|
|
|
David Vavra wrote on Tue, 03 November 2015 14:47You said all include paths are configured in the project properties but are they? If you look at Project ==> Properties ==> C/C++ General ==> Preprocessor Include Paths, Macros, etc. you will see there are selections for different languages in the Entries tab. Are the paths available to c++ also available to c? If not, add the path to the header containing the definition of INT8U to the set of c paths then rebuild the index.
If that doesn't work then what's the actual error message? It would have been nice if you had selected the Problems view in you snapshots instead of the Console view.
Yes, include path lists are identical for C and C++ on the "Preprocessor Include Paths" tab.
Problem list contains only records like "Symbol 'xxxx' could not be resolved", "Type 'xxxx' could not be resolved" and "Field 'xxxx' could not be resolved" for symbols undelied by red. All of them are types, variables and struct fields from included header files.

Attachment: c_file_2.png
(Size: 128.49KB, Downloaded 9065 times)
|
|
|
|
Re: Indexer can`t resolve symbols in C files, but resolve them in C++ files [message #1713831 is a reply to message #1713386] |
Fri, 06 November 2015 18:52   |
Eclipse User |
|
|
|
Yes, I run Eclipse and compiler on Windows 8.1 but build for ARM7-TDMI controller.
I use GNUARM, manually written makefile and it builds the project without errors. Only Eclipse indexer says that it can`t resolve type and variable symbols from included headers in C files
I have made many experiments on Eclipse end found some strange "features" (I think these are bugs):
1. If header is included in C files only, it believes that this is C file. Otherwise it believes that this is С++ file. It does not matter, which language is set for the header file.
2. When indexer parses C files (the files, which have "GNU C" language mappings) it assumes that " __cplusplus" is defined. So, it is not possible to write in a header file somthing like this:
#ifdef __cplusplus
extern "C" {
#endif
if this file is not included in at least one C++ file. Writing "#undef __cplusplus" before includes in C files solves some problems
Eventually I added the line "believe that all "*.C" files are "GNU C++" files" to the project language mappings and this solves all my problems. I believe that this is not correct, but it works for some reason for CDT indexer.
|
|
|
|
Re: Indexer can`t resolve symbols in C files, but resolve them in C++ files [message #1713875 is a reply to message #1713832] |
Sat, 07 November 2015 12:05  |
Eclipse User |
|
|
|
If you are including a header into a C source, it had better conform to C. Treating something you arbitrarily labelled a C++ file as a C file is more than reasonable -- it's required. There are only minor differences in syntax between C and C++ so, as far as CDT is concerned, telling it all files are C++ will only cause it to overlook any C++ forms that show up in a C file that are in fact errors.
My guess is that declarations in header files are cached and likely C definitions are somehow different than C++ definitions in the cache. Some of the differences are important though. For example, in C, it's possible to have simultaneously both a struct X and an int X. The standard mapping of .h is to both C++ and C and I wouldn't be surprised if they are scanned independent of use and always treated as C++ files or perhaps the order they are encountered that determines how they are treated.
Looks like this may be a bug but whether it is or not is a matter of opinion.
[Updated on: Sat, 07 November 2015 12:07] by Moderator Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.05329 seconds