svn commit: r268137 - head/sys/sys

Pedro Giffuni pfg at FreeBSD.org
Fri Jun 19 16:48:00 UTC 2015



On 06/19/15 11:24, Dimitry Andric wrote:
> 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.

Oh yes, I had missed line 258 (and 320), sorry for the false alarm.

FWIW, there is still a minor issue: older compilers aren't supposed
to take __dead2 at the beginning. When i was discussing the
attached patch, bde suggested we should resurrect __dead.

Pedro.





> 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: include_Noreturn.diff
Type: text/x-patch
Size: 4513 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20150619/17be9363/attachment.bin>


More information about the svn-src-head mailing list