On Fri, Jan 25, 2013 at 2:38 PM, Mark Kettenis <[email protected]> wrote:
>> Date: Thu, 03 Jan 2013 16:10:02 -0500
>> From: "Todd C. Miller" <[email protected]>
>>
>> On Thu, 03 Jan 2013 13:42:06 EST, "Todd C. Miller" wrote:
>>
>> > On Wed, 02 Jan 2013 20:03:32 -0430, Andres Perera wrote:
>> >
>> > > `gcc -ansi` defines __STRICT_ANSI which could be checked before
>> > > setting __POSIX_VISIBLE >=  200809 in <sys/cdefs.h>
>> >
>> > It probably makes the most sense to simply convert __STRICT_ANSI
>> > to _ANSI_SOURCE.
>>
>> Something like this for example.
>>
>>  - todd
>>
>> Index: sys/sys/cdefs.h
>> ===================================================================
>> RCS file: /home/cvs/openbsd/src/sys/sys/cdefs.h,v
>> retrieving revision 1.34
>> diff -u -r1.34 cdefs.h
>> --- sys/sys/cdefs.h   14 Aug 2012 20:11:37 -0000      1.34
>> +++ sys/sys/cdefs.h   3 Jan 2013 21:06:44 -0000
>> @@ -357,9 +357,17 @@
>>  #endif
>>
>>  /*
>> - * _ANSI_SOURCE means to expose ANSI C89 interfaces only.
>> + * GCC defines __STRICT_ANSI when -ansi, -std=c89 or -std=c99 is specified.
>> + * In the case of -std=c99, __STDC_VERSION__ will be set to 199901.
>> + */
>> +#if defined(__STRICT_ANSI) && !defined(_ANSI_SOURCE)
>> +# define _ANSI_SOURCE                1
>> +#endif
>
> I don't think we should define _ANSI_SOURCE in our headers; I've had
> the following diff in one of my trees for a while.  There's some
> fallout in xenocara/dist/Mesa though.  And I suspect there will be
> some ports issues as well.  So we probably want to leave this alone
> until after the next release.

fwiw, i also agree that using a name not prefixed by `__' to keep
header-internal state is suboptimal if the user hasn't defined the
name


> Index: cdefs.h
> ===================================================================
> RCS file: /cvs/src/sys/sys/cdefs.h,v
> retrieving revision 1.34
> diff -u -p -r1.34 cdefs.h
> --- cdefs.h     14 Aug 2012 20:11:37 -0000      1.34
> +++ cdefs.h     25 Jan 2013 19:01:57 -0000
> @@ -361,8 +361,8 @@
>   * If the user defines it in addition to one of the POSIX or XOPEN
>   * macros, assume the POSIX/XOPEN macro(s) should take precedence.
>   */
> -#if defined(_ANSI_SOURCE) && !defined(__POSIX_VISIBLE) && \
> -    !defined(__XPG_VISIBLE)
> +#if (defined(_ANSI_SOURCE) || defined(__STRICT_ANSI__)) && \
> +    !defined(__POSIX_VISIBLE) && !defined(__XPG_VISIBLE)
>  # define __POSIX_VISIBLE       0
>  # define __XPG_VISIBLE         0
>  # define __ISO_C_VISIBLE       1990
> @@ -385,7 +385,8 @@
>   * macros is defined or if the user explicitly asks for them.
>   */
>  #if !defined(_BSD_SOURCE) && \
> -   (defined(_ANSI_SOURCE) || defined(__XPG_VISIBLE) || 
> defined(__POSIX_VISIBLE))
> +   (defined(_ANSI_SOURCE) || defined(__STRICT_ANSI__) || \
> +    defined(__XPG_VISIBLE) || defined(__POSIX_VISIBLE))
>  # define __BSD_VISIBLE         0
>  #endif

Reply via email to