Hi, my project uses lib/_Noreturn.h, but gets a warning when compiled with "-std=c99 -pedantic":
warning: _Noreturn functions are a C11-specific feature By placing an #error directive in the code below during testing, I confirmed the preprocessor is incorrectly hitting the condition marked /* _Noreturn works as-is. */ #ifndef _Noreturn # if (defined __cplusplus \ && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ || (defined _MSC_VER && 1900 <= _MSC_VER)) \ && 0) /* [[noreturn]] is not practically usable, because with it the syntax extern _Noreturn void func (...); would not be valid; such a declaration would only be valid with 'extern' and '_Noreturn' swapped, or without the 'extern' keyword. However, some AIX system header files and several gnulib header files use precisely this syntax with 'extern'. */ # define _Noreturn [[noreturn]] # elif ((!defined __cplusplus || defined __clang__) \ && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ || 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \ || (defined __apple_build_version__ \ ? 6000000 <= __apple_build_version__ \ : 3 < __clang_major__ + (5 <= __clang_minor__)))) /* _Noreturn works as-is. */ # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C # define _Noreturn __attribute__ ((__noreturn__)) # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) # define _Noreturn __declspec (noreturn) # else # define _Noreturn # endif #endif The correct behavior would be to respect the value of __STDC_VERSION__ which I set with the -std=c99 compiler flag. Here are the values of the relevant macros in my environment: #define __GNUC__ 4 #define __GNUC_MINOR__ 2 #define __STDC_VERSION__ 199901L #define __apple_build_version__ 10001145 #define __clang_major__ 10 #define __clang_minor__ 0 Here is my compiler version: Apple LLVM version 10.0.0 (clang-1000.11.45.5) Target: x86_64-apple-darwin17.7.0 Also tested that on my system it would be OK to define _Noreturn to be "__attribute__ ((__noreturn__))". That option causes no warnings. Thanks for your help. Hope there's a way to simplify/fix the logic in the header.