Archives
D Programming
DD.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++ - __BASE_FILE__
Walter Could we have a __BASE_FILE__ (or equivalent) in DMC/C++? It corresponds to the name of the source file specific to the compiler. Matthew Oct 17 2003
I think there is already such as thing as __FILE__ const char * __BASE_FILE__ = __FILE__; Jan Matthew Wilson wrote:Walter Could we have a __BASE_FILE__ (or equivalent) in DMC/C++? It corresponds to the name of the source file specific to the compiler. Matthew Oct 17 2003
"Matthew Wilson" <matthew stlsoft.org> wrote in message news:bmoa2j$3f1$1 digitaldaemon.com...Walter Could we have a __BASE_FILE__ (or equivalent) in DMC/C++? It corresponds to the name of the source file specific to the compiler. Oct 17 2003
__FILE__ gives the name of whatever source file it is used in __BASE_FILE__ gives the name of the source file specified to the compiler // header.h const char hname[] = __FILE__; const char sname[] = __BASE_FILE__; // source1.c #include "header.h" printf("%s\n", hname); // Prints "header.h" printf("%s\n", sname); // Prints "source1.c" // source2.cpp #include "header.h" cout << hname << endl; // Prints "header.h" cout << sname << endl; // Prints "source2.cpp" GCC has this, and some others may do. I'm using this in a section in the book and, of course, it'd be good to say that DMC++ also supports. IIRC, there is talk of adding this to the C & C++ standards, though I forget the source for that rememberance. I know you don't like adding things to the compiler, but this must be simple to do, is done elsewhere, would be very useful, and it'd get DMC++ more mentions here and there. ;) "Walter" <walter digitalmars.com> wrote in message news:bmp7ev$1ami$1 digitaldaemon.com..."Matthew Wilson" <matthew stlsoft.org> wrote in message news:bmoa2j$3f1$1 digitaldaemon.com...Walter Could we have a __BASE_FILE__ (or equivalent) in DMC/C++? It corresponds to the name of the source file specific to the compiler. Oct 17 2003
Thanks for explaining it. I did a google search on it, and it appears to be gcc only. There were 949 hits on it, vs 119,000 hits for __FILE__. I was unable to find any rationale for __BASE_FILE__. It isn't hard to implement, but the trouble with it is once it is there, it is there forever. Breaking existing code is bad for business <g>. There are several DMC features that I wish I could remove now, but they are needed for unknown quantities of legacy code. More features mean more bloat, more documentation, more testing, and more bugs. (Reminds me of when I worked for Boeing, we were constantly reminded that every pound of weight was a cost that kept on costing money, in every airplane in every moment it flew.) I need a strong rationale for it. If you can find the ANSI C proposal for it, that might do. -Walter "Matthew Wilson" <matthew stlsoft.org> wrote in message news:bmphi1$1ou0$1 digitaldaemon.com...__FILE__ gives the name of whatever source file it is used in __BASE_FILE__ gives the name of the source file specified to the compiler // header.h const char hname[] = __FILE__; const char sname[] = __BASE_FILE__; // source1.c #include "header.h" printf("%s\n", hname); // Prints "header.h" printf("%s\n", sname); // Prints "source1.c" // source2.cpp #include "header.h" cout << hname << endl; // Prints "header.h" cout << sname << endl; // Prints "source2.cpp" GCC has this, and some others may do. I'm using this in a section in the book and, of course, it'd be good to say that DMC++ also supports. IIRC, there is talk of adding this to the C & C++ standards, though I forget the source for that rememberance. I know you don't like adding things to the compiler, but this must be Oct 17 2003
A simple example (from the book): // CUTrace.h extern void CUTraceHelper(char const *file, char const *msg, va_list args); static void CUTrace(char const *message, ...) { va_list args; va_start(fmt, args); CUTraceHelper(__BASE_FILE__, message, args); va_end(args); } I understand your reticence, and am not surprised by your refusal. Still, it would be nice ... "Walter" <walter digitalmars.com> wrote in message news:bmpom6$23ie$1 digitaldaemon.com...Thanks for explaining it. I did a google search on it, and it appears to Oct 17 2003
"Matthew Wilson" <matthew stlsoft.org> wrote in message news:bmq1oc$2f2g$2 digitaldaemon.com...A simple example (from the book): // CUTrace.h extern void CUTraceHelper(char const *file, char const *msg, va_list Oct 17 2003
"Matthew Wilson" <matthew stlsoft.org> wrote in message news:bmoa2j$3f1$1 digitaldaemon.com...Walter Could we have a __BASE_FILE__ (or equivalent) in DMC/C++? Oct 17 2003
|