Thursday, February 3, 2022

[SOLVED] What do the input and output "languages" for the -x flag in GCC mean?

Issue

I am trying to compile a piece of code that was previously compiled with gfortran in ifort instead. The old compile line has a -xf95-cpp-input option in it that doesn't make sense to me.

Looking in the GCC docs, it seems like the -x option tells the compiler to ignore the file extension of the source code file, and parse it explicitly with the language you tell it to. So for example, I could run gfortran -xf77 myfunkycode.lulwut and it will parse my .lulwut file as an f77 file.

This makes sense, but then what does f95-cpp-input or c++-cpp-output mean? What do 'input' and 'output' even mean in this context? I'm guessing "input" is the source code? "Output" is the object file? According to the docs, -x is just for choosing the "language of the input file," why is 'output' in the language list at all?


Solution

f95-cpp-input

Compile the source file as f95 file with cpp preprocessor.

c++-cpp-output

Compile the source file as C++ file without cpp preprocessor.

What do 'input' and 'output' even mean in this context?

Just a convention I guess.



Answered By - KamilCuk
Answer Checked By - Willingham (WPSolving Volunteer)