MSVC /FA GCC equivalent

I'm using GCC to compiler and I want to print the full path of the file using __FILE__ , but GCC shows only the name of the file. In MSVC is the same, but you can use an argument /FC (Full Path of Source Code File in Diagnostics) and it works. Is there any equivalent to GCC?

int main(int argc, char ** argv)
{
    std::cout << __FILE__ << std::endl;
    return 0;
}

I couldn't find any equivalent, but I realized that __FILE__ macro expands to the name of the current input file via the path used by the preprocessor to open the file. So it will depend on what is passed to the compiler.

I solved it using CMake as build system. When CMake creates the MakeFile it uses the full path in the variable CMAKE_SOURCE_DIR , this way __FILE__ will print exactly what we expect.

链接地址: http://www.djcxy.com/p/72526.html

上一篇: MSVC中的“Escape”和“Clobber”等效

下一篇: MSVC / FA GCC等效