Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Indexer can`t resolve symbols in C files, but resolve them in C++ files
Indexer can`t resolve symbols in C files, but resolve them in C++ files [message #1713343] Tue, 03 November 2015 14:06 Go to next message
Alim Adzhiev is currently offline Alim AdzhievFriend
Messages: 4
Registered: November 2015
Junior Member
index.php/fa/23819/0/index.php/fa/23818/0/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

index.php/fa/23818/0/

index.php/fa/23819/0/
  • Attachment: c_file.png
    (Size: 94.95KB, Downloaded 8959 times)
  • Attachment: cpp_file.png
    (Size: 94.86KB, Downloaded 9299 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 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
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 Go to previous messageGo to next message
Alim Adzhiev is currently offline Alim AdzhievFriend
Messages: 4
Registered: November 2015
Junior Member
David Vavra wrote on Tue, 03 November 2015 14:47
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.



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.

index.php/fa/23820/0/
  • Attachment: c_file_2.png
    (Size: 128.49KB, Downloaded 8971 times)
Re: Indexer can`t resolve symbols in C files, but resolve them in C++ files [message #1713386 is a reply to message #1713343] Tue, 03 November 2015 17:55 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
Obviously, you are doing a cross-compile, though you do not say it aloud.

Please check that you're having the correct include paths (including the compiler built-in CPU definitions) in the 'includes' branch of the project tree. If not, the project properties page provides settings to do it.




--

Tauno Voipio
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 Go to previous messageGo to next message
Alim Adzhiev is currently offline Alim AdzhievFriend
Messages: 4
Registered: November 2015
Junior Member
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 #1713832 is a reply to message #1713831] Fri, 06 November 2015 19:06 Go to previous messageGo to next message
Alim Adzhiev is currently offline Alim AdzhievFriend
Messages: 4
Registered: November 2015
Junior Member
Now I have chanded the language mapping "C source files are GNU C++ files" to "C header files are GNU C files" and this works too!
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 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
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]

Report message to a moderator

Previous Topic:Fully remote projects using PTP or ?
Next Topic:a stranger error on vector<string>
Goto Forum:
  


Current Time: Thu Sep 26 02:11:03 GMT 2024

Powered by FUDForum. Page generated in 0.03657 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top