This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Last <sys/cdefs.h> change

On 05/23/2013 10:58 AM, Corinna Vinschen wrote:
On May 23 10:03, Sebastian Huber wrote:
On 05/23/2013 09:44 AM, Corinna Vinschen wrote:
On May 23 09:30, Sebastian Huber wrote:

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. */
/* 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.


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

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. */

Does that mean _Alignas, _Alignof, _Noreturn, and _Thread_local
are also defined since 4.6?

Ok, this is a good question.  Sorry for sending such sloppy proposals.

I don't quite grok the !defined(__STDC_VERSION__) here.  gcc 4.6 defines
_Static_assert independently from the -std setting and independently
from -ansi.  It's just there, always.  The coreutils header assumes that
_Static_assert exists because it found that it's compiled with gcc 4.6
or later.  It uses the _Static_assert in a way which works with the
builtin version of gcc.  This collides with the definition of
_Static_assert in cdefs.h.  Now, with your change, cdefs.h would fall
back to its own definition again if __STDC_VERSION__ is defined, thus
your change would break coreutils again.

The only broken thing here is coreutils. They set -std=gnu99 and use C11 features. They use also _Static_assert() in a way that seems to be not available with pre C11 means.

I think now that your patch is perfect for this situation. Since these defines are directly from the latest FreeBSD version this means that coreutils are also broken here (I guess nobody cares about this).

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  :
PGP     : Public key available on request.

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]