Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform.h error when building with GCC 13 using C++14 #906

Closed
jaskij opened this issue Jun 25, 2024 · 8 comments · Fixed by #909
Closed

platform.h error when building with GCC 13 using C++14 #906

jaskij opened this issue Jun 25, 2024 · 8 comments · Fixed by #909

Comments

@jaskij
Copy link
Sponsor

jaskij commented Jun 25, 2024

Working or some minor improvements, and wanted to test them using C++14. Forced it in CMakeLists.txt. This started erroring out in platform.h because char8_t is a reserved identifier in C++20. The only way to get rid of the error (which seems a false positive given the codebase) was to add

add_compile_options(-Wno-c++20-compat)

CMake patch to force C++14:

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,6 +32,8 @@ add_library(etl::etl ALIAS ${PROJECT_NAME})
 
 include(GNUInstallDirs)
 
+add_compile_options(-std=c++14)
+
 target_include_directories(${PROJECT_NAME} ${INCLUDE_SPECIFIER} INTERFACE
         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>

Error:

[24/303] Building CXX object test/CMakeFiles/etl_tests.dir/murmurhash3.cpp.o
FAILED: test/CMakeFiles/etl_tests.dir/murmurhash3.cpp.o 
/usr/bin/c++ -DETL_DEBUG -I/home/jaskij/projects/deps/etl/test/../include -isystem /home/jaskij/projects/deps/etl/test/UnitTest++/.. -std=gnu++20 -std=c++14 -fno-omit-frame-pointer -fno-common -Wall -Wextra -Werror -Wfloat-equal -Wuseless-cast -Wshadow -Wnull-dereference -MD -MT test/CMakeFiles/etl_tests.dir/murmurhash3.cpp.o -MF test/CMakeFiles/etl_tests.dir/murmurhash3.cpp.o.d -o test/CMakeFiles/etl_tests.dir/murmurhash3.cpp.o -c /home/jaskij/projects/deps/etl/test/murmurhash3.cpp
In file included from /home/jaskij/projects/deps/etl/test/murmurhash3.cpp:10:
/home/jaskij/projects/deps/etl/test/../include/etl/platform.h:361:25: error: identifier ‘char8_t’ is a keyword in C++20 [-Werror=c++20-compat]
  361 |   typedef uint_least8_t char8_t;
@jaskij
Copy link
Sponsor Author

jaskij commented Jun 25, 2024

using ETL_CXX_STANDARD to set the C++ version causes the same error, with the same workaround

@jwellbelove
Copy link
Contributor

Try defining ETL_NO_SMALL_CHAR_SUPPORT as 0 in etl_profile.h or in the compiler settings.

@jaskij
Copy link
Sponsor Author

jaskij commented Jun 25, 2024

Won't that create issues elsewhere? Since it's simply a forward-compatibility warning.

@jwellbelove
Copy link
Contributor

It tells the ETL that the compiler has a native char8_t type.

@jaskij
Copy link
Sponsor Author

jaskij commented Jun 25, 2024

Ah! But it doesn't have char8_t.

I'm using GCC 13, but compiling in C++14 mode. This is basically a warning saying that the line would be an error if it was compiled in C++20 mode. Which won't happen because of the #ifdefs, but GCC seems to miss it.

@jwellbelove
Copy link
Contributor

We may have to disable this warning, as I can't see any way to solve this other than not defining char8_t for <C++20, which is not a real solution.

@jwellbelove
Copy link
Contributor

What is the GCC warning number for this?

@jaskij
Copy link
Sponsor Author

jaskij commented Jun 27, 2024

As far as I'm aware, GCC does not number their warnings, instead using names. I've opened #909 with a proposed solution.

@jaskij jaskij closed this as completed Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants