
__FILE__ doesn't contain path in VC7 ?
Jul 2002 06:04:43 in microsoft.public.vc.language, Karl Lehmann
Quote:
>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
>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.
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