[rfc] add __FILE__ and __LINE__ to internal_error()

J.T. Conklin jtc@redback.com
Mon Dec 4 15:02:00 GMT 2000


>>>>> "Andrew" == Andrew Cagney <ac131313@cygnus.com> writes:

Andrew> "J.T. Conklin" wrote:
>> Unfortunately, without requiring gcc or C9X, we can't use macros with
>> variable argument lists.  Otherwise, I would recommend that internal-
>> error() and internal_verror() be macros that expand __FILE__ and __LINE__
>> before calling "real" functions under the hood.

Andrew> I'll strongly concure with this sentiment.  I've used systems
Andrew> (1) that have tried to hide the passing of __FILE__ and
Andrew> __LINE__ while still supporting varargs.  Those experiences
Andrew> led me to conclude that while having explicit __FILE__ and
Andrew> __LINE__ arguments was a pain, it was far less of a pain then
Andrew> trying to set up and then get people to consistently use
Andrew> convoluted macros that did the same thing.

I've used a debug malloc package that re-defined malloc(), free(),
etc. with macros that supplied __FILE__ and __LINE__ to underlying
functions.  This worked well, but those functions all have a fixed
number of arguments.  I wouldn't want to consider any mechanism to 
do the same without "real" support for variable argument macros.  
All the preprocessor subterfuge I've been able to think of so far 
seems fragile in one way or another.  At the very least, explicitly
providing __FILE__ and __LINE__ will be solid.

Andrew> The only pratical alternative I could think of was to drop
Andrew> varargs from internal_error().

Perhaps we can revisit this in 11 years :-). 

        --jtc

-- 
J.T. Conklin
RedBack Networks


More information about the Gdb-patches mailing list