In gcc
we have -x
option that use to specify how to treat source files.
For example suppose we have a C code source file without any extension like .c
.
In gcc
simply using -x c
force compiler to read source file as a valid C code.
gcc -x c csourcecode -o out
Is there any similar option for gfortran
?
From the helpful gcc manual: [Note 1]
You can specify the input language explicitly with the
-x
option:-x language
Specify explicitly the language for the following input files (rather than letting the compiler choose a default based on the file name suffix). This option applies to all following input files until the next
-x
option. Possible values for language are:(snip)
f77 f77-cpp-input f95 f95-cpp-input
If you're using a Unix-y system and you took the precaution of installing the gcc documentation package (apt-get install gcc-doc
on debian/ubuntu-like systems), then you could have found that information directly by typing
info gcc --index-search=x
because the GCC info files are index by option name. Most of the time you don't need to type --index-search=
; info gcc x
would suffice.
gfortran
is just another front-end for the Gnu compiler collection ("gcc" for short), and accepts any options that would be accepted by the gcc
command.