Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 26 Feb 2024 03:47:22 +0000
From: Gabriel Ravier <gabravier@...il.com>
To: musl@...ts.openwall.com, Rich Felker <dalias@...c.org>,
 Jules Maselbas <jmaselbas@...v.net>
Subject: Re: [PATCH v2] prevent from redefining __STDC_UTF_{16,32}__
 macros

On 2/26/24 02:17, Rich Felker wrote:
> On Thu, Jan 25, 2024 at 03:14:40PM +0100, Jules Maselbas wrote:
>> Undefine any previous __STDC_UTF_{16,32}__ macros before defining
>> them to prenvent any warnings of redefining macros.
>>
>> ---
>> v2:
>>   - changed `#if !define(...)` guard to `#undef`, as suggested by Rich Felker
>>
>> I encountered this "issue" trying to compile a program with the -isystem
>> option to override toolchain/installed musl headers with one from source.
>>
>>   include/stdc-predef.h | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/include/stdc-predef.h b/include/stdc-predef.h
>> index af1a2799..5ccd884d 100644
>> --- a/include/stdc-predef.h
>> +++ b/include/stdc-predef.h
>> @@ -7,7 +7,10 @@
>>   #define __STDC_IEC_559__ 1
>>   #endif
>>   
>> +#undef __STDC_UTF_16__
>>   #define __STDC_UTF_16__ 1
>> +
>> +#undef __STDC_UTF_32__
>>   #define __STDC_UTF_32__ 1
>>   
>>   #endif
>> -- 
>> 2.43.0
> I merged this, but now gcc warns about undefining them if system
> header warnings aren't suppressed. I'm not sure what the justification
> is for that... *sigh*
>
> Rich

It appears as though since 2001 GCC makes it so that any redefinition or 
undefinition of any macro with a name starting with "__STDC_" (with 
hard-coded exceptions for __STDC_FORMAT_MACROS, __STDC_LIMIT_MACROS and 
__STDC_CONSTANT_MACROS) always results in a warning (from reading the 
code this doesn't seem to be tied to any -W switch, so it's simply 
entirely impossible to work around)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.