Просмотр исходного кода

enable __USE_ISOC11 for C++17

stdlib.h declares aligned_alloc only under __USE_ISOC11, which C++ code
could reach only via the _GNU_SOURCE the compiler predefines. On a non
_GNU_SOURCE system, the C++ compiler should still see all C11 functions
as C++17 is based on C11 (See:
 https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0063r3.html)

Consequently, also enable __USE_ISOC11 if we have a C++ compiler with
C++17 or newer as standard.

Signed-off-by: Christian Pötzsch <christian.poetzsch@kernkonzept.com>
Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
Christian Pötzsch 1 день назад
Родитель
Сommit
b0d1445a7e
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      include/features.h

+ 5 - 2
include/features.h

@@ -247,9 +247,12 @@
 # define _SVID_SOURCE	1
 #endif
 
-/* This is to enable the ISO C11 extension.  */
+/* This is to enable the ISO C11 extension. ISO C++17 incorporates the
+   ISO C11 library, so enable it for C++17 as well: __STDC_VERSION__ is
+   not defined when compiling C++.  */
 #if (defined _ISOC11_SOURCE \
-     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L))
+     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) \
+     || (defined __cplusplus && __cplusplus >= 201703L))
 # define __USE_ISOC11	1
 #endif