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: Florian Weimer <fweimer at redhat dot com>
- To: Zack Weinberg <zackw at panix dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 10 May 2016 16:22:49 +0200
- 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>
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
int
main (void)
{
printf ("%d\n", SYMBOL);
return 0;
}
and GCC 5.3, I get:
t.c: In function âmainâ:
t.c:11:13: warning: SYMBOL is deprecated
printf ("%d\n", SYMBOL);
^
The caret diagnostic isn't great, but it's better than nothing.
Florian