Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

msvc's equivalent of gcc's __BASE_FILE__

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 #includes.


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.

like image 525
hate-engine Avatar asked Mar 19 '13 19:03

hate-engine


People also ask

What is __ file __ in C?

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.

What is __ Size_type __?

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.

What is __ LINE __ in C?

__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.

Does clang define __ GNUC __?

(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.


2 Answers

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.

like image 151
Bentoy13 Avatar answered Sep 27 '22 18:09

Bentoy13


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

like image 35
Anthony Sottile Avatar answered Sep 27 '22 19:09

Anthony Sottile