[cfe-dev] module config_macros and _FOO_SOURCE

Richard Smith richard at metafoo.co.uk
Thu Oct 24 18:00:07 PDT 2013


Hi,

glibc's headers have _FOO_SOURCE configuration macros. These would
naturally map to config_macros in a glibc module, *except* that glibc does
this sort of thing:

// foo.h
#ifdef _FOO_SOURCE
#undef _BAR_SOURCE
#define _BAR_SOURCE 1
#endif

If we then include a modularized foo.h:

#include <foo.h>

we get an immediate problem: when the preprocessor sees the include, it
imports the version of the module with _BAR_SOURCE undefined, but when the
parser sees the corresponding import, it thinks we're trying to import a
different version of the module, because _BAR_SOURCE is now defined.

We could fix this by suppressing the warning if the macro definition comes
from the same module that we're importing (or possibly any module which
depends on that module). Is there a better way? Alternatively, we could
deem that headers that use the same macro name as both input and output are
not compatible with modules, and should be rewritten to not do that?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131024/8c222383/attachment.html>


More information about the cfe-dev mailing list