[Insight-developers] Re: [Fwd: Re: [ITK 0005255]: Usage of id as a variable name causes error in Objective-C++ projects including some ITK headers.]

Mathieu Coursolle mcoursolle at rogue-research.com
Fri Aug 17 11:10:19 EDT 2007


Hi Luis,

I'll first commit replacement of the conflicting id's.

Ok for me to use "identifier" ;).

Then I'll try to test the ObjC++ TRY_COMPILE test on a 
windows machine to make sure that the ObjC++ header tests
are not built. I'll commit that one as soon as it is
tested.

Thanks!

Mathieu


>
>Hi Mathieu,
>
>Have you tried this in a machine that *does not*
>have an Objective-C compiler ?
>
>If so,
>then it sounds good to me to commit the changes.
>
>
>BTW: the variable name "identifier" looks much
>      better than "idx". Verbosity is very helpful
>      for long term maintenance.
>
>
>    Thanks
>
>
>       Luis
>
>
>------------------------
>Mathieu Coursolle wrote:
>> Hi,
>> 
>> I added a TRY_COMPILE in the /ITK_SOURCE_DIR/CMakeLists.txt file
>> to check if the compiler can compile Objective-C++:
>> 
>> #----------------------------------
>-------------------------------------------
>> # Test for an Objective-C++ compiler.
>> TRY_COMPILE(ITK_OBJCXX_COMPILER
>>             ${ITK_BINARY_DIR}/CMakeTmp
>>             ${ITK_SOURCE_DIR}/CMake/itkTestObjCxxCompiler.mm)
>> 
>> itkTestObjCxxCompiler.mm just declares an ObjC interface.
>> 
>> For each header test, I then add an ObjC++ equivalent if
ITK_OBJCXX_COMPILER
>> is true.
>> 
>> So if no one objects, I'll commit the fix to avoid the id conflict
>> (replacing "id" variables 
>> in included files by "identifier" or "idx").
>> 
>> Should if commit the TRY_COMPILE at the same time?
>> 
>> Thank you!
>> 
>> MAthieu
>> 
>> 
>>>Hi  Sean,
>>>
>>>
>>>   Yeap, let's forget about the evil option.
>>>
>>>We certainly shouldn't follow the dumb example
>>>that Microsoft put with #defining MIN and MAX      :-/
>>>
>>>---
>>>
>>>About conditioning the build of the .mm test:
>>>
>>>You may want to check with the CMake gurus in the
>>>CMake users list,... but I would guess that a
>>>TRY_COMPILE for a Objective-C minimal program is
>>>what you need to determine if the compiler is
>>>available.
>>>
>>>Unless there is already a standard environment
>>>variable for the Objective-C compiler, similar
>>>to the CC and CXX variables for the C and C++
>>>compilers. Is there such a thing ?
>>>
>>>
>>>
>>>   Luis
>>>
>>>
>>>
>>>----------------------
>>>Sean McBride wrote:
>>>
>>>>On 8/16/07 11:08 AM, Luis Ibanez said:
>>>>
>>>>
>>>>
>>>>>I'm assuming that the .mm test is subject to finding the Objective-C
>>>>>compiler in the CMakeLists.txt.
>>>>>
>>>>>That is, many of the machines in the Dashboard may not have an
>>>>>Objective-C compiler installed.
>>>>
>>>>
>>>>Currently the CMakeLists.txt puts the whole thing in 'IF(APPLE)', but
>>>>not all Mac OS X compilers necessarily support Objective-C.  icc does
>>>>not for example.  Also, I believe gcc supports Obj-C even on non-Apples
>>>>platforms.
>>>>
>>>>So testing for an Obj-C++ compiler is probably best.  We'll try that
out...
>>>>
>>>>
>>>>
>>>>>Apart from that, it sound like a good idea to me to have this as
>>>>>a permanent test. Otherwise we can easily forget and accidentally
>>>>>use an "id" variable again.
>>>>
>>>>
>>>>Glad you agree!
>>>>
>>>>
>>>>
>>>>>Yet another option is to use the "evil Microsoft" approach and
>>>>>#define "id" as a class that will produce a compilation error,
>>>>>similar to what we do for ConceptChecking. In this case we don't
>>>>>need to have an Objective-C compiler available.
>>>>>The evil #define could be put in one of the top ITK headr files.
>>>>
>>>>
>>>>Evil indeed.  I think I'd rather the status quo. :)
>>>>
>>>
>> 
>> 
>> 
>




More information about the Insight-developers mailing list