libk  Diff

Differences From Artifact [46cfa15699]:

To Artifact [7135ae8006]:


     1      1   #ifndef KIcore
     2      2   #define KIcore
     3      3   #include <k/type.h>
     4      4   #include <k/io.h>
     5      5   #include <k/str.h>
            6  +
            7  +#ifdef __cplusplus
            8  +extern "C" {
            9  +#endif
     6     10   
     7     11   typedef struct kvar {
     8     12   	ksraw name;
     9     13   	ksraw val;
    10     14   	char* platform;
    11     15   } kvar;
    12     16   
................................................................................
    77     81   #		endif
    78     82   #	endif
    79     83   #	if (__STDC_VERSION__ >= 201103L)
    80     84   #		define KFstd_c11
    81     85   #		define KVstd c11
    82     86   #	endif
    83     87   #	ifdef __cplusplus
           88  +#		define KFstd_c89
    84     89   #		define KFstd_cpp
    85     90   #		define KVstd c++
    86     91   #		if (__cplusplus >= 201103L)
    87     92   #			define KFstd_cpp11
    88     93   #			define KVstd c++11
    89     94   #		endif /* TODO: add more */
    90     95   #	endif
................................................................................
   106    111    * being defined in C++ or K&R C. */
   107    112   #if defined (__cplusplus) && ! defined(KFclean)
   108    113   #	if __cplusplus >= 201103L
   109    114   #		define null nullptr
   110    115   #	else
   111    116   #		define null ((void*)0)
   112    117   #	endif
   113         -#elif defined __STDC__
          118  +#elif defined __STDC__ && (!defined __clang__ || defined KFclean)
   114    119   	enum { null = 0 };
   115    120   	/* believe it or not, this is actually
   116    121   	 * completely legal. doesn't even raise
   117         -	 * a single warning. i was surprised too. */
          122  +	 * a single warning in GCC. i was surprised
          123  +	 * too. alas, it later turned out that
          124  +	 * clang will throw a fit about this, so
          125  +	 * we only use the enum method if __clang__
          126  +	 * is undefined, or if the alternative is
          127  +	 * no null keyword at all. */
   118    128   #elif ! defined(KFclean)
   119    129   #	define null ((void*)0)
   120    130   #endif
          131  +
          132  +#ifndef KFclean
          133  +#	ifdef __cplusplus
          134  +#		define noreturn [[ noreturn ]]
          135  +#	elif __STDC_VERSION__ >= 201103L
          136  +#		define noreturn _Noreturn
          137  +#	else
          138  +#		define noreturn
          139  +#	endif
          140  +#endif
   121    141   
   122    142   #ifdef __cplusplus
   123         -#	define noreturn [[ noreturn ]]
          143  +	[[noreturn]] void kstop(stat_long code);
   124    144   #elif __STDC_VERSION__ >= 201103L
   125         -#	define noreturn _Noreturn
          145  +	_Noreturn void kstop(stat_long code);
   126    146   #else
   127         -#	define noreturn
          147  +	void kstop(stat_long code);
   128    148   #endif
   129    149   
   130         -noreturn void kstop(stat_long code);
   131         -
   132         -#ifdef KFclean
   133         -#	undef noreturn
          150  +#ifdef __cplusplus
          151  +}
   134    152   #endif
   135    153   
   136    154   #endif