issue with continuation character in macro expansion
Steve Kargl
sgk@troutmask.apl.washington.edu
Tue Sep 2 21:07:00 GMT 2014
On Tue, Sep 02, 2014 at 01:39:57PM -0700, Kshitij wrote:
> > Just remove the &.
>
> But that breaks compilation with other compilers such as pgi, ifort.
>
Those compilers aren't using a C preprocessor. The
Fortran continuation symbol '&' has zero significance
to a C preprocessor. If you're going to use preprocessing
then use all of its facilities.
#ifdef GFORTRAN
#define CONT
#else
#define CONT &
#endif
#define PRINTER(a, b) print *, a, b
program main
implicit none
PRINTER("helo", CONT
"world")
end program main
% gfc5x -cpp -E -DGFORTRAN -o h.zxc h.f90
% cat h.zxc
# 1 "h.f90"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "h.f90"
program main
implicit none
print *, "helo", "world"
end program main
% gfc5x -cpp -DGFORTRAN -o z h.f90 && ./z
heloworld
I'm not sure if the above #ifdef junk will work
with PGI and Intel.
--
Steve
More information about the Fortran
mailing list