Preprocessor
Ian Rutt
i.c.rutt@bristol.ac.uk
Wed May 4 15:00:00 GMT 2005
Hi,
I've been trying to use gfortran with code containing preprocessor
lines. For this sample code:
-------------------------------------------------------------------
program test_pp
#ifdef SINGLE
integer,parameter :: rk=4
#else
integer,parameter :: rk=8
#endif
end program test_pp
-------------------------------------------------------------------
I get this output:
-------------------------------------------------------------------
Warning: test_dp.f90:4: Illegal preprocessor directive
Warning: test_dp.f90:6: Illegal preprocessor directive
Warning: test_dp.f90:8: Illegal preprocessor directive
In file test_dp.f90:7
integer,parameter :: rk=8
1
Error: Symbol 'rk' at (1) already has basic type of INTEGER
-------------------------------------------------------------------
If I compile with -E (run preprocessor only), I don't get any errors.
Should this code compile or not? Have I made some sort of mistake in my
installation (e.g. environment variables)?
I'm using GCC 4.1.0 20050415 (experimental).
I realise that preprocessor directives are not part of the f95 standard,
but most other compilers support them, and they're a very useful
extension.
Thanks,
Ian
More information about the Fortran
mailing list