This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/2] Deprecate inclusion of sys/sysmacros.h by sys/types.h.
- From: Zack Weinberg <zackw at panix dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Fri, 13 May 2016 08:32:01 -0400
- Subject: Re: [PATCH 2/2] Deprecate inclusion of sys/sysmacros.h by sys/types.h.
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1461444595 dot git dot zackw at panix dot com> <361004a869a7731e6f8161be9fe5da9c5446dc99 dot 1461444595 dot git dot zackw at panix dot com> <571DC63C dot 7080708 at redhat dot com> <CAKCAbMjcn_K=_qbbSL4wFiX6ygHePrXyjcyB1T_aHLwgs=5GJQ at mail dot gmail dot com> <5731EC82 dot 20205 at panix dot com> <5731EEB9 dot 2040004 at redhat dot com>
On 05/10/2016 10:22 AM, Florian Weimer wrote:
> On 05/10/2016 04:13 PM, Zack Weinberg wrote:
>> On 04/25/2016 09:50 AM, Zack Weinberg wrote:
>>> On Mon, Apr 25, 2016 at 3:24 AM, Florian Weimer <fweimer@redhat.com>
>>> wrote:
>>>>
>>>> Why do we need these new functions? Recent GCC has support for
>>>> emitting
>>>> warnings from macros, if that's what you need.
>>>
>>> I shall look into the warnings-from-macros feature; maybe it will get
>>> me out of having to use __REDIRECT.
>>
>> Assuming the feature you were thinking of is
>>
>> _Pragma("GCC warning \"...\"")
>>
>> it is not useful for this task, because _Pragma accepts only a _single_
>> string literal as its argument; you cannot use string literal
>> concatenation to assemble a message.
>
> I'm not sure which compiler version you are using but with
>
> #include <stdio.h>
>
> #define warn1(msg) _Pragma (#msg)
> #define warn(msg) warn1 (GCC warning msg)
>
> #define SYMBOL warn ("SYMBOL is deprecated") 1
#define warn1(msg) _Pragma (#msg)
#define warn(msg) warn1 (GCC warning msg)
#define lengthy_explanation(name) \
"This is a long explanation about why `" #name "' is deprecated."
#define SYMBOL warn(lengthy_explanation(SYMBOL)) 1
int main(void) { return SYMBOL; }
=>
test.c: In function âmainâ:
test.c:9:13: warning: This is a long explanation about why `
int main(void) { return SYMBOL; }
And that is the point at which I gave up.
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71102)
zw