This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/2] Deprecate inclusion of sys/sysmacros.h by sys/types.h.

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 <>
>>> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]