I am trying to compile a huge, world-famous numerical code for weather forecasting, written mainly in Fortran 90, which uses cpp extensively and works successfully with PGI, Intel and gfortran. Now I have inherited a version in which experts have added several hundred cases of variable macros. They use Intel and fpp, which are apparently a bit more Fortran-oriented and can make everything work. I need to use gfortran and I was not able to get cpp to work with this code with its new additions.
An important simplification of the problem is as follows:
Code for preprocessing:
PRINT *, "Hello"
#define adderv(...) (myadd(__VA_ARGS__))
sumv = adderv(1, 2, 3, 4, 5)
Using cpp without an option -traditionalwill handle a variable macro, but not Fortran concatenation:
$ cpp -P t.F90
PRINT *, "Hello"
sumv = (myadd(1, 2, 3, 4, 5))
, -traditional , :
$ cpp -P -traditional t.F90
t.F90:2:0: error: syntax error in macro parameter list
#define adderv(...) (myadd(__VA_ARGS__))
^
PRINT *, "Hello"
sumv = adderv(1, 2, 3, 4, 5)
.
gpp , , . ... __VA_ARGS__. , ...
PRINT *, "Hello"
sumv = adderv(1, 2, 3, 4, 5)
$ gpp t.F90
PRINT *, "Hello"
sumv = (myadd(__VA_ARGS__))
, , , , , Fortran . .
PRINT *, "Hello" // "Don"
PRINT *, "Hello" /&
& / "Don"
cpp gpp , - , . , (, concat ) , .
- roygvib -C. , , Fortran C. , , , :
$ cat t.f90
PRINT *, "Hello"
#define adderv(...) (myadd(__VA_ARGS__))
sumv = adderv(1, 2, 3, 4, 5)
-P -C, , ++ ( Fortran concat), C-comment:
$ /lib/cpp -P -C t.F90
PRINT *, "Hello"
sumv = (myadd(1, 2, 3, 4, 5))
( , cpp) , "" cpp.
, , script (, mycpp), cpp, , C, .
, , C-. , , , , , - C-.
- , , .