# itkMathematicalMorphologyEnums.h compile error with GCC 13 on Linux

**URL:** https://discourse.itk.org/t/itkmathematicalmorphologyenums-h-compile-error-with-gcc-13-on-linux/6377
**Category:** Uncategorized
**Created:** [December 29, 2023, 3:48pm UTC](https://discourse.itk.org/t/itkmathematicalmorphologyenums-h-compile-error-with-gcc-13-on-linux/6377 "2023-12-29T15:48:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![imikejackson](https://discourse.itk.org/user_avatar/discourse.itk.org/imikejackson/32/35_2.png) [@imikejackson](https://discourse.itk.org/u/imikejackson)
#### Post date: [December 29, 2023, 3:48pm UTC](https://discourse.itk.org/t/itkmathematicalmorphologyenums-h-compile-error-with-gcc-13-on-linux/6377/1 "2023-12-29T15:48:36Z")

</div>

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

```auto
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:

```auto
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"

```

---

<div class="post-metadata">

### Author: ![shai-ikko](https://discourse.itk.org/user_avatar/discourse.itk.org/shai-ikko/32/2842_2.png) [@shai-ikko](https://discourse.itk.org/u/shai-ikko)
#### Post date: [January 8, 2024, 3:12pm UTC](https://discourse.itk.org/t/itkmathematicalmorphologyenums-h-compile-error-with-gcc-13-on-linux/6377/2 "2024-01-08T15:12:25Z")

</div>

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)

> [@imikejackson](#):
>
> ```auto
> $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>
> 
> ```

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [January 8, 2024, 5:06pm UTC](https://discourse.itk.org/t/itkmathematicalmorphologyenums-h-compile-error-with-gcc-13-on-linux/6377/3 "2024-01-08T17:06:05Z")

</div>

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:

> <https://github.com/InsightSoftwareConsortium/ITK/blob/d45127b5a3296b7f1721b57e0ffe8e0071d0c64f/Modules/Core/Common/include/itkIntTypes.h#L26-L29>

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

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [January 9, 2024, 10:30am UTC](https://discourse.itk.org/t/itkmathematicalmorphologyenums-h-compile-error-with-gcc-13-on-linux/6377/4 "2024-01-09T10:30:12Z")

</div>

Just submitted:

> <https://github.com/InsightSoftwareConsortium/ITK/pull/4387>
>
> Follow-up to pull request https://github.com/InsightSoftwareConsortium/ITK/pull/…3250 commit c173dfd803acf943d9ab80683ac4133fea29cdf5 "STYLE: Remove \`std::\` prefix from types that work without it" by Lee Newberg (@Leengit), March 6, 2022.

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”.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [January 9, 2024, 1:38pm UTC](https://discourse.itk.org/t/itkmathematicalmorphologyenums-h-compile-error-with-gcc-13-on-linux/6377/5 "2024-01-09T13:38:26Z")

</div>

> [@Niels\_Dekker](#):
>
> Just to avoid having to type `std::` for each little integer type!

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.

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [January 9, 2024, 2:25pm UTC](https://discourse.itk.org/t/itkmathematicalmorphologyenums-h-compile-error-with-gcc-13-on-linux/6377/6 "2024-01-09T14:25:49Z")

</div>

> [@blowekamp](#):
>
> This file would be better described as a legacy portability and compatibility header with just a couple specific ITK integer types.

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.
