I want get current file path,like in a.cpp,I can get
/home/workspace/src/a.cpp
How can I get this path?
I want get current file path,like in a.cpp,I can get
/home/workspace/src/a.cpp
How can I get this path?
You can use the standard macro __FILE__
to which expands to a string literal that contains the path of the current source file.
Starting from C++20, you can use default constructed std::source_location
.
I couldn't comment due to the reputation requirement.
But you might find this useful, a way to retrieve directory on Linux & Windows.
Hope this help!