chiark / gitweb /
Improve checking for C99-style varargs macros.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 10 Jan 2016 13:51:04 +0000 (13:51 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 29 May 2016 13:40:40 +0000 (14:40 +0100)
commite674612eb9e1a1dde2522260163a93a13ed44a0f
treedebf2bfbd37a8c2925fa5ec3f5699b782e1a7385
parentb5130310e64d10370f0ed36f20ce24ad3c84dc16
Improve checking for C99-style varargs macros.

This is a rather sad story.  C99 introduced `variadic macros'
(gratuitously incompatible with GCC's better thought-out existing
feature for doing the same thing).  GCC implements the feature, and
enables it by default.  Unfortunately, GCC doesn't declare conformance
with C99 by default (by defining `__STDC_VERSION__' appropriately), so
the naïve test doesn't actually work unless you give GCC some extra
options.

Now that we have a place for `preliminary utilities' in the header file,
define a new macro `SOD__HAVE_VARARGS_MACROS' to report the feature's
availability to generated code, and use this to guard definitions which
make use of the feature.

Apparently (https://gcc.gnu.org/c99status.html) the feature was added to
GCC in version 2.95; I'm testing for version three or later because it's
easy.  But this isn't enough.  If GCC isn't fully committed to the C99
feature set, then `-pedantic' mode will issue warnings about the use of
variadic macros.  Normally we could suppress these with some hacking
involving `__extension__' or `#pragma GCC diagnostic', but GCC's
preprocessor isn't clever enough to deal with any of that.  Instead, we
reach for the big hammer and have header files declare themselves to be
`system headers', which means that GCC stops trying to warn about them
at all.

This is really quite a long way from being an ideal situation.
doc/SYMBOLS
doc/output.tex
lib/sod.h
src/class-output.lisp
src/module-output.lisp