[CMake] With gcc is __FILE__ with full path. Is there a workaround?

Eric Noulard eric.noulard at gmail.com
Mon Apr 2 16:11:10 EDT 2007


2007/4/2, Manfred Rebentisch <mrebentisch at comparat.de>:
> Thank you Filipe,
>
> Am Sonntag, 1. April 2007 23:20 schrieb Filipe Sousa:
> >
> > what about using basename()?
> >
> I do use a Macro:
>
> #define CP_PREFIX(varname, functionname)      \
>         static const char* varname  = __FILE__ ":" functionname
>
> and use it:
>
> int func(void)
> {
>    CP_PREFIX(prefix, "func");
>    return printf("%s: error msg x\n", prefix);
> }
>
> The line with return and printf is only the example of use. I use other
> functions.
> With this macro you cannot use a function.
>
> Another idea?

May be.

May be you can use predefined
 C99  __func__ or GCC specific __FUNCTION__ macros
and then you should be able to use:

printf("%s:%s error msg x\n", basename(__FILE__), __FUNCTION__);

nevertheless my man page says that basename could modify
its argument which may gives you unexpected result in this case...



-- 
Erk


More information about the CMake mailing list