[CMake] Eclipse generator - basic macros

Michael Jackson mike.jackson at bluequartz.net
Tue Jul 14 14:39:27 EDT 2009


  Jul 14, 2009, at 2:26 PM, Alexander Neundorf wrote:

> On Tuesday 14 July 2009, Miguel A. Figueroa-Villanueva wrote:
>> On Tue, Jul 14, 2009 at 11:40 AM, Benjamin Schindler wrote:
>>> Miguel A. Figueroa-Villanueva wrote:
>>>> On Mon, Jul 13, 2009 at 10:31 AM, Benjamin Schindler wrote:
>>>>> I'm working on a project which builds both on linux and windows. I
>>>>> generated
>>>>> an eclipse project out of it which works basically fine but it's  
>>>>> not
>>>>> able to
>>>>> recognize i.e. the __GNUC__ macro (and probably any other macro  
>>>>> defined
>>>>> per
>>>>> default on gcc) are not recognized by eclipse. That means that  
>>>>> by using
>>>>> a header like:
>>>>>
>>>>> #if defined(_MSC_VER) && (_MSC_VER >= 1300)
>>>>> #ifdef FLOW_DLL_EXPORT
>>>>> #define FLOW_DLL _declspec(dllexport)
>>>>> #else
>>>>> #define FLOW_DLL _declspec(dllimport)
>>>>> #endif
>>>>> #else
>>>>> #ifdef __GNUC__
>>>>> #define FLOW_DLL
>>>>> #endif
>>>>> #endif
>>>>>
>>>>> and then declaring a class like:
>>>>>
>>>>> class FLOW_DLL something { .... };
>>>>> will fool eclipse's parser. When I remove the #ifdef __GNUC__, it
>>>>> works. Is
>>>>> this an issue in the eclipse generator or in the eclipse parser?
>>
>> [...]
>>
>>> Well, you are right about the greyed out area which is in short  
>>> what I
>>> ment (The project builds just fine). I would not mind this in any  
>>> way,
>>> but the issue is that classes utilizing that FLOW_DLL macro will be
>>> marked with Syntax error (because that symbol is then not defined)  
>>> and
>>> thus, code completion is not available at all for these classes  
>>> hich is a
>>> big usability issue here
>>
>> Yes, I'm well aware that this is a big usability problem... just
>> wanted to verify the source of the problem.
>>
>> Ok, maybe you can work around this by adding a snippet such as:
>>
>> if (UNIX) # or if (CMAKE_COMPILER_IS_GNUC)
>>  add_definitions(__GNUC__)
>>  # actually, I would use a different variable here and change the  
>> code
>> above endif
>>
>> Then the variable should be added to the project files. Please let me
>> know if this works.
>
> We already query gcc for the system include dirs, do we also need to  
> query it
> for the builtin macros and put that information somewhere ?
>
> Alex

Using the form I sent earlier I do not have any of these problems. All  
my source files are parsed and indexed correctly. Am I missing  
something or doing something wrong?

Mike Jackson




More information about the CMake mailing list