[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
GNULIB_POSIXCHECK, remove, and gl_oset
From: |
Eric Blake |
Subject: |
GNULIB_POSIXCHECK, remove, and gl_oset |
Date: |
Mon, 28 Sep 2009 15:13:24 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Bruno,
I tried compiling m4 with -DGNULIB_POSIXCHECK, to see if I was missing any
useful modules. To my surprise, gl_oset.h failed to compile:
In file included from ../../lib/gl_avltree_oset.h:21,
from ../../src/output.c:27:
../../lib/gl_oset.h:236:76: macro "remove" passed 2 arguments, but takes just 1
POSIX states that:
Any function declared in a header may also be implemented as a macro defined in
the header, so a function should not be declared explicitly if its header is
included. Any macro definition of a function can be suppressed locally by
enclosing the name of the function in parentheses, because the name is then not
followed by the <left-parenthesis> that indicates expansion of a macro function
name.
In other words, it is legal for a system to #define remove(x), and so any use
of the name remove as a user identifier must be tolerant of the existence of
such a function-like macro.
I see two options - either rewrite gl_oset.h to call vtable->(remove)(set,elt),
or rewrite gl_oset.h and clients to use a different vtable member function
pointer name that does not clash with the standardized name remove. Which
would you prefer?
Meanwhile, the workaround for m4 is to import the remove module, so that it
does not pick up the GNULIB_POSIXCHECK function-like definition of remove
(although this is just bulk if m4 itself doesn't use remove).
--
Eric Blake
- GNULIB_POSIXCHECK, remove, and gl_oset,
Eric Blake <=