Preprocessor statements in 'include'd files

Tim Prince tprince@myrealbox.com
Thu Jan 18 02:55:00 GMT 2007


Schamil Wackenhut wrote:
> Hi,
>
> is it possible to use preprocessor statements in included files?
>
> An example:
>
> a.f:
>       program hallo
>       
>       include 'sdf'
> #ifdef ASD
>       write(*,*) 'HalloASD'
> #else
>       write(*,*) 'Hallo'
> #endif
>       end
>
> sdf:
>       INTEGER sdf
> #ifdef ASD
>          PARAMETER (sdf=1)
> #else
>          PARAMETER (sdf=2)
> #endif
>
> So, when i try to compile it with:
> gfortran -x f77-cpp-input -DASD a.f
> i get following error messages:
> Warning: sdf:2: Illegal preprocessor directive
> Warning: sdf:4: Illegal preprocessor directive
> Warning: sdf:6: Illegal preprocessor directive
>  In file sdf:5
>
>      Included at a.f:2
>
>             PARAMETER (sdf=2)                                           
>                            1
> Error: PARAMETER attribute conflicts with PARAMETER attribute at (1)
>
> tia & best regards,
> schamil
>
> ps: please cc on reply
>
>
>   
You would need a cpp #include rather than a Fortran include.



More information about the Fortran mailing list