Re: Short form of __FILE__




"Lukas Ruf" <ruf@xxxxxxxxx> wrote in message
news:slrndueqqb.blc.ruf@xxxxxxxxxxxxxxxxxx
Dear all,

for debugging purposes, I like the pre-compiler macros

__FILE__, __FUNCTION__, __LINE__

I have been wondering if there is a short form of __FILE__ that
provides only the filename without path.

I am using gcc as available in Debian unstable:

gcc (GCC) 4.0.3 20060128 (prerelease) (Debian 4.0.2-8)


Reading the info pages on gcc has not revealed what I am looking
for. Hence my question....


__FILE__ contains whatever path is given to the compiler.

consider a simple 'test.c' ...

#include <stdio.h>
int main(void){puts(__FILE__); return 0;}

If you compile test.c like this: gcc -E test.c

You will see __FILE__ is "test.c".

If you compile it like this gcc -E ./test.c

You will see __FILE__ is "./test.c".

--
==============
*Not a pedant*
==============


.



Relevant Pages

  • Re: How do I install this missing library?
    ... you really should be carefully following LSTC's installation ... libg2c is part of gcc. ... to tell a newcomer to compile. ... like the source code to GNU tar, and make sure you understand what's ...
    (comp.os.linux.misc)
  • Re: HPGCC Questions ladies and gentlemen!!!
    ... No matter how you slice it in order to compile a C program you need to know ... it took a few hours just to get gcc running in my computer ... of the students that used an ide in the c++ class I took a few years ago. ... so why not use a data inspector if it's available? ...
    (comp.sys.hp48)
  • Re: Aquarius prolog so fast?
    ... Mercury cannot do all this because Mercury cannot keep track of the fact ... you need this capability quite rarely, ... Why not the alternative GCC back-end, ... While Mercury can compile to the internal data structures of the gcc backend, ...
    (comp.lang.prolog)
  • Re: Just starting out in C
    ... was based on the ANSI standard as it was being developed. ... Some words about gcc: ... gcc provides some extensions to the language that aren't supported by ... For example, to compile the Hello, World program, use the command line ...
    (comp.lang.c)
  • Re: Question about gcc on OS X 10.0.4.11 Tiger
    ... running Linux and gcc 4.0.2. ... How do I switch to a different version of gcc to compile with on OS X ... fgetsis a libc function and is not really part of the compiler. ... int main(int argc, char* argv){ ...
    (comp.sys.mac.programmer.help)