问题
I am trying to get the absolute path of the compiled file at compile time in C++. I am aware of the __FILE__
macro - however, the macro can be evaluated to either absolute path, or a relative path, depending on the preprocessor's arguments.
I would like to ensure that my __FILE__
(or any other macro) evaluates to a full, absolute path of the file. Is there a way to reliably do it cross-platform? (I am compiling for VS2013, VS2015, GCC on ubuntu, GCC on MinGW)
来源:https://stackoverflow.com/questions/50124235/c-file-macro-with-absolute-path