itkMathematicalMorphologyEnums.h compile error with GCC 13 on Linux

Has anyone else run across this compile error with ITK (5.2.1, 5.3)?

In file included from $SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx:19:
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/include/itkMathematicalMorphologyEnums.h:41:8: warning: elaborated-type-specifier for a scoped enum must not use the 'class' keyword
   41 |   enum class Algorithm : uint8_t
      |   ~~~~ ^~~~~
      |        -----
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/include/itkMathematicalMorphologyEnums.h:41:14: error: use of enum 'Algorithm' without previous declaration
   41 |   enum class Algorithm : uint8_t
      |              ^~~~~~~~~
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/include/itkMathematicalMorphologyEnums.h:41:26: error: 'uint8_t' was not declared in this scope
   41 |   enum class Algorithm : uint8_t
      |                          ^~~~~~~
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/include/itkMathematicalMorphologyEnums.h:23:1: note: 'uint8_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
   22 | #include "ITKMathematicalMorphologyExport.h"
  +++ |+#include <cstdint>
   23 | 
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/include/itkMathematicalMorphologyEnums.h:42:3: error: default member initializer for unnamed bit-field
   42 |   {
      |   ^
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/include/itkMathematicalMorphologyEnums.h:52:107: error: 'Algorithm' in 'class itk::MathematicalMorphologyEnums' does not name a type
   52 |                                         operator<<(std::ostream & out, const MathematicalMorphologyEnums::Algorithm value);
      |                                                                                                           ^~~~~~~~~
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx:25:67: error: 'Algorithm' in 'class itk::MathematicalMorphologyEnums' does not name a type
   25 | operator<<(std::ostream & out, const MathematicalMorphologyEnums::Algorithm value)
      |                                                                   ^~~~~~~~~
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx: In lambda function:
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx:30:41: error: 'itk::MathematicalMorphologyEnums::Algorithm' has not been declared
   30 |       case MathematicalMorphologyEnums::Algorithm::BASIC:
      |                                         ^~~~~~~~~
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx:32:41: error: 'itk::MathematicalMorphologyEnums::Algorithm' has not been declared
   32 |       case MathematicalMorphologyEnums::Algorithm::HISTO:
      |                                         ^~~~~~~~~
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx:34:41: error: 'itk::MathematicalMorphologyEnums::Algorithm' has not been declared
   34 |       case MathematicalMorphologyEnums::Algorithm::ANCHOR:
      |                                         ^~~~~~~~~
$SRC_DIR/itk/Modules/Filtering/MathematicalMorphology/src/itkMathematicalMorphologyEnums.cxx:36:41: error: 'itk::MathematicalMorphologyEnums::Algorithm' has not been declared
   36 |       case MathematicalMorphologyEnums::Algorithm::VHGW:
      |                                         ^~~~~~~~~

this is our build script:

cmake -S "../itk" -B . -G "Ninja" $CMAKE_ARGS \
  -DCMAKE_BUILD_TYPE:STRING=Release \
  -D CMAKE_INSTALL_PREFIX:PATH="$PREFIX" \
  -DCMAKE_SYSTEM_PREFIX_PATH:PATH="$PREFIX" \
  -DEigen3_DIR=${PREFIX}/share/eigen3/cmake \
  -DBUILD_SHARED_LIBS:STRING=ON \
  -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=11.0 \
  -DCMAKE_SKIP_INSTALL_RPATH:BOOL=OFF \
  -DCMAKE_SKIP_RPATH:BOOL=OFF \
  -DCMAKE_CXX_STANDARD:STRING=17 \
  -DCMAKE_CXX_STANDARD_REQUIRED:BOOL=ON \
  -DBUILD_DOCUMENTATION:BOOL=OFF \
  -DBUILD_EXAMPLES:BOOL=OFF \
  -DBUILD_TESTING:BOOL=OFF \
  -DKWSYS_USE_MD5:BOOL=ON \
  -DITK_LEGACY_REMOVE:BOOL=ON \
  -DITK_FUTURE_LEGACY_REMOVE:BOOL=ON \
  -DITK_LEGACY_SILENT:BOOL=OFF \
  -DITKV4_COMPATIBILITY:BOOL=OFF \
  -DITK_USE_SYSTEM_EIGEN:BOOL=ON \
  -DITK_USE_SYSTEM_HDF5:BOOL=ON \
  -DITKGroup_Core:BOOL=ON \
  -DITKGroup_Filtering:BOOL=ON \
  -DITKGroup_Registration:BOOL=ON \
  -DITKGroup_Segmentation:BOOL=ON \
  -DITK_BUILD_DEFAULT_MODULES:BOOL=OFF \
  -DModule_ITKTestKernel:BOOL=OFF \
  -DModule_ITKReview:BOOL=OFF \
  -DModule_SCIFIO=OFF \
  -DModule_ITKMetricsv4:BOOL=OFF \
  -DModule_ITKOptimizersv4:BOOL=OFF \
  -DModule_ITKRegistrationMethodsv4:BOOL=OFF \
  -DModule_ITKConvolution:BOOL=ON \
  -DModule_ITKDenoising:BOOL=ON \
  -DModule_ITKImageNoise:BOOL=ON \
  -DITKGroup_IO:BOOL=OFF \
  -DITKGroup_Core:BOOL=OFF \
  -DModule_ITKGDCM:BOOL=OFF \
  -DModule_ITKIOBioRad:BOOL=ON \
  -DModule_ITKIOBMP:BOOL=ON \
  -DModule_ITKIOGE:BOOL=ON \
  -DModule_ITKIOGIPL:BOOL=ON \
  -DModule_ITKIOImageBase:BOOL=ON \
  -DModule_ITKIOIPL:BOOL=ON \
  -DModule_ITKIOJPEG:BOOL=ON \
  -DModule_ITKIOMeta:BOOL=ON \
  -DModule_ITKIOMRC:BOOL=ON \
  -DModule_ITKIONIFTI:BOOL=ON \
  -DModule_ITKIONRRD:BOOL=ON \
  -DModule_ITKIOPNG:BOOL=ON \
  -DModule_ITKIOStimulate:BOOL=ON \
  -DModule_ITKIOTIFF:BOOL=ON \
  -DModule_ITKIOVTK:BOOL=ON \
  -DModule_ITKIOTransformBase:BOOL=ON \
  -DITK_CUSTOM_LIBRARY_SUFFIX:STRING="-NX-$ITK_VERSION"

Did you notice this part of the error message, with a hint from the compiler as to what might be wrong?
(I should say, I would expect itkMathematicalMorphologyEnums.h to include <cstdint> if it depends on it)

Thanks for discussing this issue.

FYI, ITK has its own header, “itkIntTypes.h”, which places all those typedef’s from <cstdint> into the itk namespace:

Just to avoid having to type std:: for each little integer type!

1 Like

Just submitted:

But that’s just a matter of style, of course. Technically, #include <cstdint> should also work, but within ITK source code, we decided to use those type aliases from “itkIntTypes.h”.

1 Like

Historically, ITK originally had its own fixed width integer types. And they were switched to the C99 name before those name were available in all supported compilers.

This file would be better described as a legacy portability and compatibility header with just a couple specific ITK integer types.

1 Like

OK, but nowadays “itkIntTypes.h” does serve as a header file to support using integer types from <cstdint> inside the itk namespace without having to specify std:: every time.