diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f56d7ce..83692e9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,12 +118,11 @@ endforeach() # XXX - similar hints for other compilers? # if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") - add_definitions( - "-D_U_=__attribute__((unused))" - "-DNGHTTP2_NORETURN=__attribute__((noreturn))" - ) + set(HINT_UNUSED_PARAM "__attribute__((unused))") + set(HINT_NORETURN "__attribute__((noreturn))") else() - add_definitions(-D_U_ -DNGHTTP2_NORETURN) + set(HINT_UNUSED_PARAM) + set(HINT_NORETURN) endif() include(ExtractValidFlags) diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index d7db50f3..3e39463d 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -1,4 +1,10 @@ +/* Hint to the compiler that a function parameter is not used */ +#define _U_ @HINT_UNUSED_PARAM@ + +/* Hint to the compiler that a function never returns */ +#define NGHTTP2_NORETURN @HINT_NORETURN@ + /* Define to 1 if you have the `std::map::emplace`. */ #cmakedefine HAVE_STD_MAP_EMPLACE 1