@@ -2,8 +2,12 @@ #define KIcore #include #include #include + +#ifdef __cplusplus +extern "C" { +#endif typedef struct kvar { ksraw name; ksraw val; @@ -80,8 +84,9 @@ # define KFstd_c11 # define KVstd c11 # endif # ifdef __cplusplus +# define KFstd_c89 # define KFstd_cpp # define KVstd c++ # if (__cplusplus >= 201103L) # define KFstd_cpp11 @@ -109,28 +114,41 @@ # define null nullptr # else # define null ((void*)0) # endif -#elif defined __STDC__ +#elif defined __STDC__ && (!defined __clang__ || defined KFclean) enum { null = 0 }; /* believe it or not, this is actually * completely legal. doesn't even raise - * a single warning. i was surprised too. */ + * a single warning in GCC. i was surprised + * too. alas, it later turned out that + * clang will throw a fit about this, so + * we only use the enum method if __clang__ + * is undefined, or if the alternative is + * no null keyword at all. */ #elif ! defined(KFclean) # define null ((void*)0) #endif + +#ifndef KFclean +# ifdef __cplusplus +# define noreturn [[ noreturn ]] +# elif __STDC_VERSION__ >= 201103L +# define noreturn _Noreturn +# else +# define noreturn +# endif +#endif #ifdef __cplusplus -# define noreturn [[ noreturn ]] + [[noreturn]] void kstop(stat_long code); #elif __STDC_VERSION__ >= 201103L -# define noreturn _Noreturn + _Noreturn void kstop(stat_long code); #else -# define noreturn + void kstop(stat_long code); #endif -noreturn void kstop(stat_long code); - -#ifdef KFclean -# undef noreturn +#ifdef __cplusplus +} #endif #endif