This is the mail archive of the libc-alpha@sourceware.org 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 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


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