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

Manfred Rebentisch mrebentisch at comparat.de
Tue Apr 3 03:03:03 EDT 2007


Hello Filipe,

Am Montag, 2. April 2007 22:56 schrieb Filipe Sousa:
> Eric Noulard wrote:
> > 2007/4/2, Manfred Rebentisch <mrebentisch at comparat.de>:
> >
> > 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...
>
> @google:
> #define FILE ((strrchr(__FILE__, '/') ? : __FILE__- 1) + 1)

May be. But then there is a function call every time, I use the declation. It 
is not a good idea. 
Remember: my question was, if it is possible to tell cmake, that it use only 
the filename without full path on generation of the makefile. It should be 
easy to implement that behaviour, isn*t?

Manfred


More information about the CMake mailing list