svn commit: r268137 - head/sys/sys

Dimitry Andric dim at FreeBSD.org
Fri Jun 19 16:24:43 UTC 2015


On 19 Jun 2015, at 17:02, Pedro Giffuni <pfg at freebsd.org> wrote:
> 
>> On 19/06/2015 05:16 a.m., David Chisnall wrote:
>>> I only just caught this (having seen the fallout from NetBSD doing the same thing in a shipping release and the pain that it’s caused):
>>> 
>>> __weak is a reserved keyword in Objective-C, please pick another name for this.  This in cdefs.h makes it impossible to include any FreeBSD standard headers in Objective-C programs (of which we have a couple of hundred in ports) if they use any of the modern Objective-C language modes.
...
> Closely related to this, we are redefining _Noreturn, which is a reserved keyword in C11.

No, sys/cdefs.h has:

   254  /*
   255   * Keywords added in C11.
   256   */
   257
   258  #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint)
[...]
   284  #if defined(__cplusplus) && __cplusplus >= 201103L
   285  #define _Noreturn               [[noreturn]]
   286  #else
   287  #define _Noreturn               __dead2
   288  #endif
[...]
   320  #endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */

So the whole block redefining all the _Xxx identifiers is skipped for
C11 and higher.

E.g.:

$ cpp -std=c99
#include <sys/cdefs.h>
_Noreturn void foo(void);
^D
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 306 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 2 "<stdin>" 2
__attribute__((__noreturn__)) void foo(void);

$ cpp -std=c11
#include <sys/cdefs.h>
_Noreturn void foo(void);
^D
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 306 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 2 "<stdin>" 2
_Noreturn void foo(void);

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20150619/5ba84b95/attachment.sig>


More information about the svn-src-head mailing list