View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005255ITKpublic2007-06-29 14:462008-01-25 10:13
ReporterMathieu Coursolle 
Assigned ToMathieu Coursolle 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0005255: Usage of id as a variable name causes error in Objective-C++ projects including some ITK headers.
DescriptionSome ITK headers include files that declare variables named "id".

"id" is a reserved key-word in Objective-C and Objective-C++ to represent any pointer to an objective-C object.

An Objective-C++ application can mix both objective-C and C++ (ex: ITK).

Therefore, if an ITK header declares a variable named id, it produces a compiler error when that header is included in an Objective-C++ project.

A solution would be to replace all use of the "id" key-word in ITK included files and replace them by some alternative (ex: theId).

Example:

itkVectorContainer.h includes itkVectorContainer.txx which implements the following:

template <typename TElementIdentifier, typename TElement>
bool
VectorContainer< TElementIdentifier , TElement >
::IndexExists(ElementIdentifier id) const
{
  return (NumericTraits<ElementIdentifier>::IsNonnegative(id)
          && (id < this->VectorType::size()));
}

The following error is produced:
itkVectorContainer.txx:137: error: cannot find protocol declaration for ''
TagsNo tags attached.
Resolution Date
Sprint
Sprint Status
Attached Files

 Relationships

  Notes
(0008071)
Luis Ibanez (manager)
2007-07-15 09:28

We will need a dashboard submission in order to find all the "id" instances that conflict with Objective C++.
(0008464)
Sean McBride (developer)
2007-08-14 17:14

Luis, so far "all instances" is only 1 instance, so this problem does not seem widespread. Since it's just renaming a variable, we will commit this fix unless you object.

To be able to find these on a dashboard, we would need a .m and/or .mm source file (Objective-C and Objective-C++ respectively) that includes many/all itk headers. I suppose a test could be created that simply compiles such a file. If the file does not compile it is because there is a parse error in one of the headers, such as by having a variable named 'id'. But this test would need constant updating, everytime there is a new ITK header. Seems painful.
(0008504)
Mathieu Coursolle (developer)
2007-08-17 14:19

The following files have been changed to replace "id" by "identifier" to avoid any conflicts with the Objective-C keyword:

/Code/Common/itkVectorContainer.txx
/Code/Numerics/Statistics/itkHistogram.txx
/Code/Numerics/Statistics/itkListSampleBase.h
/Code/Numerics/Statistics/itkListSample.txx
/Code/Algorithms/itkEuclideanDistancePointMetric.txx
/Code/SpatialObject/itkMetaTubeConverter.txx
/Code/SpatialObject/itkMetaDTITubeConverter.txx
/Code/SpatialObject/itkMetaVesselTubeConverter.txx
/Code/SpatialObject/itkMetaBlobConverter.txx
/Code/SpatialObject/itkMetaLandmarkConverter.txx
/Code/SpatialObject/itkMetaLineConverter.txx
/Code/SpatialObject/itkSurfaceSpatialObject.txx
/Code/SpatialObject/itkMetaSurfaceConverter.txx
/Code/SpatialObject/itkMetaContourConverter.txx
/Code/Patented/itkActiveShapeModelCalculator.txx
/Code/Patented/itkActiveShapeModelGradientSearchMethod.txx

Objective-C++ header tests will later be added to ensure that no other
variables are named id in ITK included files.

A TRY_COMPILE directive checks if the compiler can compile objective-C++.
If so, Objective-C++ header tests are added and compiled if testing is enabled.
(0008613)
Mathieu Coursolle (developer)
2007-08-23 10:40

CMakeLists.txt was changed to add a TRY_COMPILE to test for Objective-C++ compiler (ITK_OBJCXX_COMPILER).

The following tests were added:

/CMake/itkTestObjCxxCompiler.mm
/Testing/Code/Algorithms/itkAlgorithmsHeaderObjCxxTest.mm
/Testing/Code/BasicFilters/itkBasicFiltersHeaderObjCxxTest.mm
/Testing/Code/Common/itkCommonHeaderObjCxxTest.mm
/Testing/Code/IO/itkIOHeaderObjCxxTest.mm
/Testing/Code/Numerics/itkNumericsHeaderObjCxxTest.mm
/Testing/Code/Numerics/NeuralNetworks/itkNeuralNetworksHeaderObjCxxTest.mm
/Testing/Code/Numerics/Statistics/itkStatisticsHeaderObjCxxTest.mm
/Testing/Code/Patented/itkPatentedHeaderObjCxxTest.mm
/Testing/Code/SpatialObject/itkSpatialObjectHeaderObjCxxTest.mm

The corresponding Testing folders CMakeListx.txt file have been modified to include those tests if an Objective-C++ compiler was found.
(0010297)
Mathieu Coursolle (developer)
2008-01-25 10:13

Tests have been ran with success:
http://www.itk.org/Testing/Dashboard/20080125-0100-Nightly/Dashboard.html [^]

 Issue History
Date Modified Username Field Change
2007-08-14 17:14 Sean McBride Note Added: 0008464
2007-08-17 14:19 Mathieu Coursolle Note Added: 0008504
2007-08-23 10:22 Mathieu Coursolle Assigned To Luis Ibanez => Mathieu Coursolle
2007-08-23 10:40 Mathieu Coursolle Note Added: 0008613
2008-01-25 10:13 Mathieu Coursolle Status assigned => resolved
2008-01-25 10:13 Mathieu Coursolle Resolution open => fixed
2008-01-25 10:13 Mathieu Coursolle Note Added: 0010297
2008-01-25 10:13 Mathieu Coursolle Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team