Next: A larger FWEB example
Up: Annotating Codes with FWEB
Previous: FWEB comments
FWEB preprocessor
- You can use CPP and m4 preprocessors with Fortran programs.
- FWEB provides a powerful alternative, that is well integrated
into the system.
- FWEB macros are defined in the middle part of
FWEB sections and then used within the code part
the same way as in C. FWEB conditional constructs can
be used within the code part too.
- @m
- works like
#define
@m YES 1
@m NO 0
@m BUF_LEN 100
@m CUBE(x) (x)**3
- @#define
- same as
@m
- @m*
- this is a recursive macro: ANSI C doesn't
support those
- @m!
- a macro which cannot be redefined
- @#undef
- undefine a previously defined macro
Numeric labels of Fortran can be replaced with the #:0
construct:
@n9[-n/]
@
@m DONE #:0 // Symbolic statement label in FORTRAN.
@a
goto DONE
...
DONE:
- @#ifdef
- same as
#ifdef in CPP, equivalent to
@#if defined
- @#ifndef
- same as
#ifndef in CPP, equivalent to
@#if !defined
- @#if
- @#elif
- @#else
- @#endif
- same as the corresponding conditional code
generation constructs in CPP
Macros can be defined on the command line using the
-m switch to ftangle and fweave, e.g.,
-mA(x)=x on the command line is equivalent to @mA(x) x
in the FWEB file. This allows for conditioning the generated code from
a Makefile.
Next: A larger FWEB example
Up: Annotating Codes with FWEB
Previous: FWEB comments
Zdzislaw Meglicki
2001-02-26