C++ __FILE__ macro with absolute path

倾然丶 夕夏残阳落幕 提交于 2020-04-16 02:09:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!