preprocessor flags

Issue #87 new
Ryusuke Numata created an issue

It seems there’re three Makefile Macros (CPPFLAGS, FPPFLAGS, MACRO_DEFS) passed to preprocessors. The rule for their use
is not clear.

Here’re my understanding:
MACRO_DEFS is a collection of -D, and CPPFLAGS, FPPFLAGS are other options passed to preprocessors.
So, CPP takes CPPFLAGS + MACRO_DEFS, and FPP takes FPPFLAGS + MACRO_DEFS.

One complication is the C compiler. It implicitly performs preprocessing, and may take CFLAGS + CPPFLAGS + MACRO_DEFS.
(I here ignore optimization flags.)

Based on this understanding, CPPFLAGS can be blank. I don’t understand why it has the include options, the library options, and C options like -ffreestanding.

And, the reason that there exists CPPFLAGS and FPPFLAGS (though Fortran preprocessor is actually cpp) is because C compiler does not accept the -traditional option. This problem could have been resolved by defining MACRO_DEFS. We can remove FPPFLAGS and can do the following:
.c.o: CFLAGS + MACRO_DEFS (no CPPFLAGS)
.fpp.o: CPPFLAGS + MACRO_DEFS

Note that we should change some Makefiles in Makefiles accordingly.

Comments (2)

  1. Ryusuke Numata reporter

    I’ve created a branch, bugfix/cpp-fpp-options.

    I noticed that CPPFLAGS is automatically added when compilation. So it is not good to use CPPFLAGS as a option to Fortran preprocessor.

  2. David Dickinson

    Yes I think our current usage is probably not very consistent. It would be nice to make this more consistent and cleaner.

    MACRO_DEFS is used with the documentation system as well so should only ever contain definitions with -D

    @Peter Hill may be able to comment more on this.

  3. Log in to comment