gcc compiles assert() to code that requires linking with gcc

Zack Weinberg zack@wolery.cumb.org
Sun Jun 25 23:28:00 GMT 2000

On Sun, Jun 25, 2000 at 05:55:24PM +0900, Martin Buchholz wrote:
> I cannot create a static library that includes a call to assert() and
> that is intended for use with the native compiler as well as with gcc.

assert's helper function, __eprintf, is different from all the other
routines in libgcc.  It exists because in the past, you couldn't count
on the system <assert.h> to be standard compliant.  It might declare
fprintf, or require you to have included <stdio.h>, or not honor
NDEBUG, or something like that.  Just another of the problems we have
to patch around in the system headers - only in this case, the
solution chosen was to provide our own copy entirely, instead of
patching the system copy.  And it needed a routine it could call that
was in the implementation namespace, and that was the same across all
platforms.  Hence __eprintf.

Nowadays, the system usually gets assert.h right by itself, and gcc
can be told to forget its private version.  All you have to do is add
a couple lines to the appropriate t-* makefile fragment.  Sample from

# Use the system assert.h.

We'd be happy to take patches applying this to whatever platforms you
can verify it's safe for.


More information about the Gcc-bugs mailing list