www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - __FILE__ macro

↑ ↓ ← Karyn Chen <Karyn_member pathlink.com> writes:
I am using the __FILE__ macro but am having problems. Sometimes the macro is
replaced by the file name, File.cc, both other times it is replaced by the whole
path name like /home/dev/test/File.cc. How can I prevent the whole path name
from printing?
Nov 15 2004
↑ ↓ → Scott Michel <scottm aero.org> writes:
Karyn Chen wrote:
 I am using the __FILE__ macro but am having problems. Sometimes the macro is
 replaced by the file name, File.cc, both other times it is replaced by the
whole
 path name like /home/dev/test/File.cc. How can I prevent the whole path name
 from printing?

It depends on the file name passed to the compiler. If the command line contains "File.cc", then __FILE__ will be "File.cc". OTOH, if you pass a path on the command line, the path version is what you get. Search google for a function called "basename".
Nov 15 2004