Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Indexer's extern "C" confusion
Indexer's extern "C" confusion [message #1782683] Tue, 27 February 2018 20:40 Go to next message
Vladimir Grishchenko is currently offline Vladimir GrishchenkoFriend
Messages: 104
Registered: July 2009
Senior Member
I have some C-callable functions defined in a .cpp file, their declarations are in an extern "C" block guarded by #ifdef __cplusplus inside a header file that's included by the .cpp file. I'm unable to find references to these functions from .c files unless I also individually mark them as extern "C" in the .cpp file. Declaring them individually as extern "C" in the header file works too. Shouldn't he indexer be smart enough to recognize the #ifdef __cplusplus/extern "C" block declarations when parsing a .cpp file that includes the header with the declarations???
Re: Indexer's extern "C" confusion [message #1782743 is a reply to message #1782683] Wed, 28 February 2018 20:37 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
I have no need for it, but this could work:

Open Project Properties -> C/C++ General -> Paths and Symbols, pick the #Symbols tab and add symbol __cplusplus and value 1.


--

Tauno Voipio
Re: Indexer's extern "C" confusion [message #1782745 is a reply to message #1782743] Wed, 28 February 2018 20:52 Go to previous messageGo to next message
Vladimir Grishchenko is currently offline Vladimir GrishchenkoFriend
Messages: 104
Registered: July 2009
Senior Member
Indeed it could, I however ended up adding extern "C" to all the definitions, seems to be more of proper fix anyway.
Re: Indexer's extern "C" confusion [message #1782752 is a reply to message #1782745] Thu, 01 March 2018 03:41 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
The settings for Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc. are defined by language.
So are the settings for Paths and Symbols

In Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc.
Define a User Entry for C++ as __cplusplus (Note the double underscore)
The compiler should also set this and it should appear among the entries for the built-ins.
Maybe your compiler built-ins provider doesn't have it (e.g., Visual C/C++ doesn't have a way to list bult-ins)
Setting it as a User Entry should fix that.
Alternately, defining it in Paths and Symbols should work too.

MinGW GCC Built-ins
Note that __cplusplus is defined as 199711L by MinGW GCC
index.php/fa/32201/0/
index.php/fa/32202/0/

Adding a macro definition
index.php/fa/32203/0/

Be sure to select the proper configuration name when you do this.

[Updated on: Thu, 01 March 2018 03:51]

Report message to a moderator

Re: Indexer's extern "C" confusion [message #1782754 is a reply to message #1782752] Thu, 01 March 2018 04:23 Go to previous messageGo to next message
Vladimir Grishchenko is currently offline Vladimir GrishchenkoFriend
Messages: 104
Registered: July 2009
Senior Member
Ok, this makes more sense now. I thought the indexer should assume __cplusplus for all cpp files, but I see it can be undesirable as it needs to remain agnostic of the compiler in use. Indeed my compiler doesn't have an interface to discover the built ins. That said, isn't __cplusplus a part of the C++ standard?
Re: Indexer's extern "C" confusion [message #1782759 is a reply to message #1782754] Thu, 01 March 2018 06:14 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
The index is merely a database. It's up to the discovery providers and scanner to fill it.
The built-ins provider is the one to fill in predefined macros.
Since you don't have one, you need to do it manually.

What you might want to consider is a file that contains the definitions and add it as a user entry in
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc.

You might want to file an enhancement request in Bugzilla to have built-in defaults for standard macros.

[Updated on: Thu, 01 March 2018 06:52]

Report message to a moderator

Re: Indexer's extern "C" confusion [message #1782773 is a reply to message #1782759] Thu, 01 March 2018 09:17 Go to previous message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
I had an analogous problem with cross-compilation to a Cortex-M4 ARM. There are actually hundreds of predefined constants in the compiler (351 for Cortex-M4) in addition to the __cplusplus.

I pushed the GCC to create a header file of the includes:

arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -E -dM >cortexm4-predef.h

and added it to the indexer includes.

Many of the standard library headers depend on the constants in the predefinition file, and this keeps the indexer happy with them.


--

Tauno Voipio
Previous Topic:Exe project builds dependent libs in lib current config, not exe config
Next Topic:debug w/ MinGW-W64 & oxygen
Goto Forum:
  


Current Time: Fri Mar 29 11:21:33 GMT 2024

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

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

Back to the top