This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC's <assert.h> and C99
>>>>> "ZW" == Zack Weinberg <zack@rabi.columbia.edu> writes:
ZW> You were told, months ago, that the proper way to fix the __eprintf problem
ZW> - yes, we accept that it is a problem - is to submit a two line patch for
ZW> the target Makefile fragment for the systems you care about (e.g. t-svr4):
ZW> +# Use the system <assert.h>.
ZW> +INSTALL_ASSERT_H =
I don't believe in adding more stuff to system-specific files. Of
course, gcc is bound to be non-portable, but still one should try hard
to autoconfiscate everything.
ZW> Alternatively, you could write a clever autoconf test which determines if
ZW> the target has a C89 compliant <assert.h> and disables installation of our
ZW> header if it does. That would fix the problem for everyone, but would be
ZW> substantially harder.
Hmmmmm.
ZW> Why have you not done either of these things?
Maybe because I'm busy maintaining my own amazingly buggy free
software.
I *did* submit a patch in the area of assert/eprintf. I have heard no
response from the gcc folks, although a parallel patch to libc made it
into the sources.
ZW> ...
ZW> As to the issue of C99 requiring the appearance of the function name in the
ZW> string printed by a failed assertion - I submit that this is a library issue
ZW> and we should not worry about it. Note that assert.h is not required to be
ZW> provided by a freestanding implementation of C in either C89 or C99. (And
ZW> that argues that we should not provide it on any system, even if it's
ZW> pre-C89...)
Zack, that's a very enlightening comment. I had assumed that gcc came
with assert.h because it could not be done just as well by a libc.
Offhand, it looks hard for a libc implementor to provide an assert.h
that works for both c89 and c9x without compiler-specific hacks. How
do you test for support for __func__?
The implementor of glibc naturally provided special support for gcc,
like this:
# ifdef __GNUC__
# if __GNUC__ > 2 || (__GNUC__ == 2 \
&& __GNUC_MINOR__ >= (defined __cplusplus ? 6 : 4))
...
Martin