Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gfortran and preprocessor directives

2,661 views
Skip to first unread message

audio...@gmail.com

unread,
Jan 30, 2014, 3:12:58 AM1/30/14
to

Hullo, I am using gfortran (v. 4.1.2), and I would like to use preprocessor directives in my source code. However, if I try something like:

#if VAR

...source...

#endif

the compiler signals these as "Illegal preprocessor directive". What am I doing wrong? Thank you.

A.

\"Vladimír Fuka <"name.surnameat

unread,
Jan 30, 2014, 5:27:15 AM1/30/14
to
> the compiler signals these as "Illegal preprocessor directive". What am
> I doing wrong? Thank you.

Do you use the -cpp option?

audio...@gmail.com

unread,
Jan 30, 2014, 5:39:11 AM1/30/14
to
My version of gfortran does not recognize the -cpp flag....

Alberto Luaces

unread,
Jan 30, 2014, 6:41:22 AM1/30/14
to

> Hullo, I am using gfortran (v. 4.1.2)

Quite ancient!

gfortran should preprocess files with "F90" extension instead of
lowercase "f90".

Tim Prince

unread,
Jan 30, 2014, 6:47:16 AM1/30/14
to
http://gcc.gnu.org/onlinedocs/gfortran/Preprocessing-and-conditional-compilation.htmlhttp://gcc.gnu.org/onlinedocs/gfortran/Preprocessing-and-conditional-compilation.html
Even on Windows, gfortran (mingw and cygwin) use the .F and .F90 file
suffixes to trigger tradcpp as -cpp does.
http://gcc.gnu.org/onlinedocs/gfortran/Preprocessing-and-conditional-compilation.html
A usual way to pre-process explicitly is with a Makefile rule including e.g.
gcc -traditional-cpp -E $*.F > $*.f
where gcc -traditional-cpp has the same effect as gfortran -cpp.
If you went out of your way to find an unusual version of gfortran where
these features are stripped out, there's not much we can do for you.
Note that such versions are required by the GPL license to provide their
source code.

--
Tim Prince
0 new messages