/FC compiler switch apparently not working

Hi all,

When trying to output the __FILE__ predefined macro, I always get the file name fully qualified regardless if I have /FS set or not as a compiler option.

Is this switch not working, or is there some other compiler switch that is forcing fully qualified path names



Answer this question

/FC compiler switch apparently not working

  • legoman26

    Jonathan Caves - MSFT wrote:
    The option /ZI - support edit and continue - also forces __FILE__ to expand to the full path-name. If you don't need E'n'C try compiling with /Zi instead of /ZI.

    Fantastic!

    Thank you :)


  • memories_with_the_cup

    Without the /FC compile option, __FILE__ expands to the path to the source code file, relative from the project folder. If your file lives in another folder, you'll see something like "..\..\..\..\..\folder\folder\folder\filename.cpp". I doubt there is a workaround, other than moving the source file into the same folder as the project. __FILE__ will then expand to ".\filename.cpp".



  • Scott Stubbs

    There is no /FS compiler switch. There is a /FC compiler option, that causes the compiler to display the full path of source code files passed to the compiler in diagnostics, including for the __FILE__ macro. If /FC is not specified, the names of the files are displayed, and not the absolute paths. So, I think you make a confusion here.

  • jsin

    Sure...

    I'm using Visual C++ 2005 Express.

    Projects are simple console applications with Standard Windows Libraries. No ATL, and no CLR.

    Compiler options are set as follows:

    /Od /D "_WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MDd /Gy /Za /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W4 /nologo /c /ZI /TP /errorReport:prompt

    A sample of the code follows. When compiled, the output shows me the fully qualified path name of the file, regardless of having or not the FC switch set.

    #include <iostream>

    int main()

    {

        std::cerr << __FILE__ << std::endl;

        system("PAUSE");

        return 0;

    }


  • cell-gfx

    The option /ZI - support edit and continue - also forces __FILE__ to expand to the full path-name. If you don't need E'n'C try compiling with /Zi instead of /ZI.

  • Anderson dos Santos Pimentel

    Changed the thread name. I was distracted. Thank you :)

    However the problem persists. /FC seems to not be working.


  • JohnsonInBeijing

    I haven't changed file locations from what VS sets as a default for each project. Also the output is a fully qualified file name. Not a relative path.

    The above code outputs:

    c:\documents and settings\mario figueiredo\my documents\visual studio 2005\projects\learning\learning\main.cpp


  • Nick Piazza

    Can you provide us with an example I've tried several variations and they all work. Also which compiler are you using

  • /FC compiler switch apparently not working