Is there any equivalent of __BASE_FILE__
in Visual C++? I want to know name of the file currently being compiled by VC++.
Note: __FILE__
expands into current file, e.g. it may be one of #include
s.
From gcc's doc:
__BASE_FILE__
This macro expands to the name of the main input file, in the form of a C string constant. This is the source file that was specified as an argument when the C compiler was invoked.
The __FILE__ macro expands to a string whose contents are the filename, surrounded by double quotation marks ( " " ). If you change the line number and filename, the compiler ignores the previous values and continues processing with the new values. The #line directive is typically used by program generators.
Note that __SIZE_TYPE__ isn't a variable; it's a type. Compilers other than GCC probably do not provide it, unless they're trying to be compatible with GCC. If you want size_t , include <stddef. h> if you aren't including any of the other headers (such as <stdio. h> , <string.
__LINE__ is a preprocessor macro that expands to current line number in the source file, as an integer. __LINE__ is useful when generating log statements, error messages intended for programmers, when throwing exceptions, or when writing debugging code.
(GNU C is a language, GCC is a compiler for that language.Clang defines __GNUC__ / __GNUC_MINOR__ / __GNUC_PATCHLEVEL__ according to the version of gcc that it claims full compatibility with.
Thanks to John's comment, here is a workaround. If you simply put __BASE_FILE__=%(Filename)
, it does 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 must be written in the preprocessor page of the property page of the project.
Doesn't look like there is an equivalent: http://msdn.microsoft.com/en-us/library/b0084kay%28v=vs.80%29.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With