-1

In gcc we have -x option that use to specify how to treat source file.

For example suppose we have a csourcecode file without any extension like .c.

In gcc simply using -x c before express csourcecode force compiler to use it as valid c source code.

gcc -x c csourcecode -o out

Is there any similar option for gfortran?

sepp2k
  • 363,768
  • 54
  • 674
  • 675
EsmaeelE
  • 2,331
  • 6
  • 22
  • 31

1 Answers1

2

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.


Notes:

  1. In case it's not obvious, 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.
rici
  • 234,347
  • 28
  • 237
  • 341