Last <sys/cdefs.h> change

Sebastian Huber sebastian.huber@embedded-brains.de
Thu May 23 08:06:00 GMT 2013


On 05/23/2013 09:44 AM, Corinna Vinschen wrote:
> On May 23 09:30, Sebastian Huber wrote:
>> Hello,
>>
>> what is the reason for the change:
>> [...]
>> There is already a test for C11 some lines above:
>>
>> #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
>> /* Do nothing.  They are language keywords. */
>> #else
>> /* Not supported.  Implement them using our versions. */
>>
>> If you want C11 in GCC, you have to specify -std=c11 or -std=gnu11.
>
> gcc >= 4.6 defines _Static_assert even without -std=C11.
>
> See http://cygwin.com/ml/cygwin/2013-05/msg00310.html

In this message the problem occurs with "gcc -std=gnu99".  Asking for a C11 
feature with such a command line seems to be contradictory.

I would use this approach:

--- newlib/libc/include/sys/cdefs.h     2013-05-23 09:21:47.817952315 +0200
+++ cdefs.h     2013-05-23 10:01:28.014875569 +0200
@@ -261,15 +261,15 @@
  #define        _Thread_local           __thread
  #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
  /* Do nothing.  They are language keywords. */
+#elif !defined(__STDC_VERSION__) && __GNUC_PREREQ__(4, 6)
+/* Do nothing.  They are provided for free. */
  #else
  /* Not supported.  Implement them using our versions. */
  #define        _Alignas(x)             __aligned(x)
  #define        _Alignof(x)             __alignof(x)
  #define        _Noreturn               __dead2
  #define        _Thread_local           __thread
-#if __GNUC_PREREQ__(4, 6) && !defined(__cplusplus)
-/*  Do nothing: _Static_assert() works as per C11 */
-#elif defined(__COUNTER__)
+#ifdef __COUNTER__
  #define        _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
  #define        __Static_assert(x, y)   ___Static_assert(x, y)
  #define        ___Static_assert(x, y)  typedef char __assert_ ## y[(x) ? 1 : -1]

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the Newlib mailing list