------ FileTest.cpp ------
#include <stdio.h>
void main()
{
printf("The current file is: %s\n", __FILE__);
}
--------------------------
In VC6 (SP5), this prints the full path of the current source file,
e.g.:
The current file is: d:\code\test\filetest\filetest.cpp
However, in VC7, I only get the name of the source file, but not the
path:
The current file is: FileTest.cpp
Hence it seems that the preprocessor has changed the behavior of
__FILE__ from VC6 to VC7. Does anyone know how to get the full path in
VC7? Any help would be greatly appreciated.
Karl Lehmann
I don't have VC7, but the first place I'd look would be TFM (you
know, as in "RTFM"...) Search the MSDN for "predefined macros".
Victor
--
Please remove capital A's from my address when replying by mail
Your pointing at the preprocessor. I think you should look at the IDE.
The following uses VC6 and the command line.
C:\WINDOWS\TEMP> type FILE.cpp
char *d = __FILE__;
C:\WINDOWS\TEMP> cl file.cpp /P /C /c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
file.cpp
C:\WINDOWS\TEMP> type file.i
#line 1 "file.cpp"
char *d = "file.cpp";
C:\WINDOWS\TEMP> cl C:\WINDOWS\TEMP\file.cpp /P /C /c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
file.cpp
C:\WINDOWS\TEMP> type file.i
#line 1 "C:\\WINDOWS\\TEMP\\file.cpp"
char *d = "C:\\WINDOWS\\TEMP\\file.cpp";
C:\WINDOWS\TEMP>
--
Walter Briscoe
>The following program behaves differently in VC6 and VC7:
>
>------ FileTest.cpp ------
>#include <stdio.h>
>
>void main()
>{
> printf("The current file is: %s\n", __FILE__);
>}
>--------------------------
>
>In VC6 (SP5), this prints the full path of the current source file,
>e.g.:
>
>The current file is: d:\code\test\filetest\filetest.cpp
>
>
>However, in VC7, I only get the name of the source file, but not the
>path:
>
>The current file is: FileTest.cpp
Both VC6 and VC7 print the same bare filename for me. The differences
become apparent when __FILE__ is expanded within a #included file.
>Hence it seems that the preprocessor has changed the behavior of
>__FILE__ from VC6 to VC7. Does anyone know how to get the full path in
>VC7? Any help would be greatly appreciated.
There are some bugs in this area. For example, see this thread:
http://groups.google.com/groups?threadm=31f001c1b4bb%241cb34800%24a4e62ecf%40tkmsftngxa06
--
Doug Harrison
Microsoft MVP - Visual C++
Eluent Software, LLC
http://www.eluent.com
Tools for VC++, VS.NET, and Windows