KhronosGroup / KTX-Software

KTX (Khronos Texture) Library and Tools
Other
861 stars 225 forks source link

Clang 16 warning: Bitwise operation between different enumeration types is deprecated #774

Closed St0wy closed 9 months ago

St0wy commented 11 months ago

I am using this library in a C++23 project and it seems like this error prevents me from building.

[862/942] Building CXX object _deps/ktx-software-build/CMakeFiles/ktx.dir/Release/lib/basis_encode.cpp.o
FAILED: _deps/ktx-software-build/CMakeFiles/ktx.dir/Release/lib/basis_encode.cpp.o 
/usr/bin/c++ -DBASISD_SUPPORT_FXT1=0 -DBASISD_SUPPORT_KTX2=1 -DBASISD_SUPPORT_KTX2_ZSTD=0 -DBASISU_SUPPORT_OPENCL=0 -DBASISU_SUPPORT_SSE=1 -DKHRONOS_STATIC -DKTX_FEATURE_KTX1 -DKTX_FEATURE_KTX2 -DKTX_FEATURE_WRITE -DLIBKTX -DCMAKE_INTDIR=\"Release\" -I/home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/include -I/home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/lib/basisu/transcoder -I/home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/lib/basisu/zstd -I/home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/other_include -I/home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/utils -I/home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/lib/dfdutils -I/home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/lib/basisu -I/home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/lib/astc-encoder/Source -O3 -DNDEBUG -std=gnu++23 -Wall -Wextra -Werror -O3 -Wno-cast-function-type -Wno-pedantic -msse4.1 -MD -MT _deps/ktx-software-build/CMakeFiles/ktx.dir/Release/lib/basis_encode.cpp.o -MF _deps/ktx-software-build/CMakeFiles/ktx.dir/Release/lib/basis_encode.cpp.o.d -o _deps/ktx-software-build/CMakeFiles/ktx.dir/Release/lib/basis_encode.cpp.o -c /home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/lib/basis_encode.cpp
In file included from /home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/lib/basis_encode.cpp:24:
/home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/lib/basis_encode.cpp: In function ‘ktx_error_code_e ktxTexture2_rewriteDfd4BasisLzETC1S(ktxTexture2*, alpha_content_e, bool, swizzle_e*)’:
/home/stowy/dev/opengl-scene/build/_deps/ktx-software-src/include/KHR/khr_df.h:104:14: error: bitwise operation between different enumeration types ‘_khr_df_vendorid_e’ and ‘_khr_df_mask_e’ is deprecated [-Werror=deprecated-enum-enum-conversion]
  104 |      (((val) & (KHR_DF_MASK_ ## X)) << (KHR_DF_SHIFT_ ## X)))
      |        ~~~~~~^~~~~~~~~~~~~~~~~~~~~
// ...

cc1plus: all warnings being treated as errors

I'm on Linux with clang version 16.0.6, CMake version 3.27.4 and I downloaded the library with CPM.

MarkCallow commented 11 months ago

In the latest version of the source, since about 2 months ago, warnings as errors is a CMake config option that is off by default. This version has not been released yet, which is probably why you didn't get it from CPM. I won't have time to fix this until the beginning of October. Even then there are a couple of other items needed before I can publish a release. I suggest you either get the latest source or attempt a fix yourself. I am sorry for the delay.

St0wy commented 11 months ago

I'll use the source then. Thanks a lot !

MarkCallow commented 9 months ago

@St0wy when you build the library is it being built with std=C++23? That might explain why you see the warnings and we don't even when building with clang 16. We might need to explicitly specify which std to use when compiling the library so parent projects can't affect it.