__FILE__ doesn't contain path in VC7 ? 
Author Message
 __FILE__ doesn't contain path in VC7 ?

The following program behaves differently in VC6 and VC7:

------ FileTest.cpp ------
#include <stdio.h>

void main()
{
  printf("The current file is: %s\n",  __FILE__);

Quote:
}

--------------------------

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



Sat, 15 Jan 2005 21:04:43 GMT  
 __FILE__ doesn't contain path in VC7 ?

Quote:

> [...] Does anyone know how to get the full path in
> VC7? Any help would be greatly appreciated.

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



Sat, 15 Jan 2005 21:14:07 GMT  
 __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



Sat, 15 Jan 2005 22:36:32 GMT  
 __FILE__ doesn't contain path in VC7 ?

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

Both VC6 and VC7 print the same bare filename for me. The differences
become apparent when __FILE__ is expanded within a #included file.

Quote:
>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%24a4e...

--
Doug Harrison
Microsoft MVP - Visual C++
Eluent Software, LLC
http://www.eluent.com
Tools for VC++, VS.NET, and Windows



Sun, 16 Jan 2005 02:50:54 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. VC7 RC1 MFC library source paths don't default to the installed location

2. Program that doesn't contain the main() function

3. GetSchemeTable() doesn't always contain valid information?

4. SYSINCL.dat doesn't seem to work in VC7.1

5. VC7: cstdio doesn't put printf in std

6. Dialog containing a CTabCtrl containing a modeless dialog box, shortcuts don't work

7. Can't Get File Path of a network file

8. File->New in doc/view doesn't clear doc file name

9. Adding My Application's Path to PATH ?

10. Adding an application's path to PATH On Win NT

11. How Do I change File Open's starting path

12. how i can get my program's (EXE File ) path when it is running

 

 
Powered by phpBB® Forum Software