Skip to content

build error: comparison of different enumeration types #108827

@dacheng-gao

Description

@dacheng-gao

Description

Hi, I'm trying to build dotnet-runtime against master (commit: 7b69459), but I got the below error:

...
  [  9%] Built target precompiled_asm
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:9:38: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:12:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:114:1)') [-Werror,-Wanon-enum-enum-conversion]
      9 | c_static_assert(PAL_OperationEncrypt == kCCEncrypt);
        |                 ~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  [ 10%] Built target corguids
  [ 10%] Building CXX object vm/eventing/eventpipe/CMakeFiles/eventpipe_objs.dir/Unity/unity_0_cxx.cxx.o
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:10:38: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:12:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:114:1)') [-Werror,-Wanon-enum-enum-conversion]
     10 | c_static_assert(PAL_OperationDecrypt == kCCDecrypt);
        |                 ~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:12:34: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:19:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:131:1)') [-Werror,-Wanon-enum-enum-conversion]
     12 | c_static_assert(PAL_AlgorithmAES == kCCAlgorithmAES128);
        |                 ~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:13:34: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:19:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:131:1)') [-Werror,-Wanon-enum-enum-conversion]
     13 | c_static_assert(PAL_AlgorithmDES == kCCAlgorithmDES);
        |                 ~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:14:35: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:19:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:131:1)') [-Werror,-Wanon-enum-enum-conversion]
     14 | c_static_assert(PAL_Algorithm3DES == kCCAlgorithm3DES);
        |                 ~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:15:34: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:19:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:131:1)') [-Werror,-Wanon-enum-enum-conversion]
     15 | c_static_assert(PAL_AlgorithmRC2 == kCCAlgorithmRC2);
        |                 ~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:17:37: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:28:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:650:1)') [-Werror,-Wanon-enum-enum-conversion]
     17 | c_static_assert(PAL_ChainingModeECB == kCCModeECB);
        |                 ~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:18:37: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:28:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:650:1)') [-Werror,-Wanon-enum-enum-conversion]
     18 | c_static_assert(PAL_ChainingModeCBC == kCCModeCBC);
        |                 ~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:19:37: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:28:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:650:1)') [-Werror,-Wanon-enum-enum-conversion]
     19 | c_static_assert(PAL_ChainingModeCFB == kCCModeCFB);
        |                 ~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:20:38: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:28:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:650:1)') [-Werror,-Wanon-enum-enum-conversion]
     20 | c_static_assert(PAL_ChainingModeCFB8 == kCCModeCFB8);
        |                 ~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:22:37: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:37:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:669:1)') [-Werror,-Wanon-enum-enum-conversion]
     22 | c_static_assert(PAL_PaddingModeNone == ccNoPadding);
        |                 ~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.c:23:38: error: comparison of different enumeration types ('enum (unnamed at /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_symmetric.h:37:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/CommonCrypto/CommonCryptor.h:669:1)') [-Werror,-Wanon-enum-enum-conversion]
     23 | c_static_assert(PAL_PaddingModePkcs7 == ccPKCS7Padding);
        |                 ~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:24:48: note: expanded from macro 'c_static_assert'
     24 | #define c_static_assert(e) c_static_assert_msg(e, "")
        |                                                ^
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/Common/pal_compiler.h:23:53: note: expanded from macro 'c_static_assert_msg'
     23 | #define c_static_assert_msg(e, msg) _Static_assert((e), msg)
        |                                                     ^
  12 errors generated.
  make[2]: *** [libs-native/System.Security.Cryptography.Native.Apple/CMakeFiles/System.Security.Cryptography.Native.Apple-Static.dir/pal_symmetric.c.o] Error 1
  make[2]: *** Waiting for unfinished jobs....
  [ 10%] Building CXX object palrt/CMakeFiles/palrt.dir/guid.cpp.o
  [ 10%] Built target createdump_static
  [ 10%] Building CXX object md/compiler/CMakeFiles/mdcompiler_wks.dir/cmake_pch.hxx.pch
  [ 10%] Building CXX object md/runtime/CMakeFiles/mdruntime_wks.dir/cmake_pch.hxx.pch
  /Users/gdc/Sandbox/dotnet-runtime/src/native/libs/System.Security.Cryptography.Native.Apple/pal_x509.c:154:37: error: conditional expression between different enumeration types ('enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h:318:1)' and 'enum (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/MacTypes.h:388:1)') [-Werror,-Wanon-enum-enum-conversion]
    154 |     *pOSStatus = *ppDataOut == NULL ? errSecParam : noErr;
        |                                     ^ ~~~~~~~~~~~   ~~~~~
  1 error generated.
  make[2]: *** [libs-native/System.Security.Cryptography.Native.Apple/CMakeFiles/System.Security.Cryptography.Native.Apple-Static.dir/pal_x509.c.o] Error 1
  make[1]: *** [libs-native/System.Security.Cryptography.Native.Apple/CMakeFiles/System.Security.Cryptography.Native.Apple-Static.dir/all] Error 2
  make[1]: *** Waiting for unfinished jobs....
  [ 10%] Building CXX object palrt/CMakeFiles/palrt.dir/memorystream.cpp.o
...

Edited: Sorry to mention my clang info:

$ clang --version
Homebrew clang version 19.1.1
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/19.1.1/bin

Edited: it's the same error with apple clang:

$ clang --version
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Reproduction Steps

Run git clone dotnet/runtime and run ./build.sh.

Expected behavior

Build success.

Actual behavior

Got the above error.

Regression?

No response

Known Workarounds

No response

Configuration

OS: macOS 15
Arch: arm64 (m3)

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Securityin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions