How about a predefined #FILE, #PATH and #FUNCTION for C?

Thomas Scott Christiansen tom at puff.wisc.edu
Tue Jan 28 00:23:13 AEST 1986


On most compilers with a CPP, you have the symbols __FILE__ and
__LINE__ defined.  Consider the following error macro:

#define ERROR(function, argument, excuse)                               \
    {                                                                   \
        fprintf(stderr,"Unexpected ERROR at line %d of file \"%s\"\n",  \
            __LINE__, __FILE__ );                                       \
        fprintf(stderr,"function: %s() died (%s) from \"%s\"\n",        \
            function, argument, excuse);                                \
    }

tom



More information about the Comp.lang.c mailing list