Msvc gcc equivalent __BASE_FILE__

Is there an equivalent of __BASE_FILE__ in Visual C ++? I want to know the name of the file that VC ++ is currently compiling.

Note: __FILE__ expands to the current file, for example. it may be one of #include s.


From gcc doc:

__BASE_FILE__

This macro expands to the name of the main input file as a constant of string C. This is the source file that was specified as an argument when calling the C compiler.

+4
source share
2 answers

It doesn't seem like there is an equivalent: http://msdn.microsoft.com/en-us/library/b0084kay%28v=vs.80%29.aspx

+1
source

Thanks to John's comment, this is a workaround. If you just put __BASE_FILE__=%(Filename) , it will not make a literal string. So put it between double quotes; I also added the extension since% (Filename) does not have it.

 __BASE_FILE__="%(Filename)%(Extension)" 

This line should be written on the preprocessor page of the project properties page.

+4
source

All Articles