How to mangle names with Fortran preprocessor?

Hi all,

I need to add a prefix to names by using preprocessor. The idea is best expressed thus:

#define PREFIX_  ns1_   /*<< this definition comes from outside */

#define MANGLE(name) CONCAT(EXPAND(PREFIX_),name)
#define EXPAND(a) a
#define CONCAT(a,b)  CONCAt(a,b)
#define CONCAt(a,b)  a/**/b      /*<<note: operator ## not supported */
      call MANGLE(foo)  /*<<fortran should see: call ns1_foo */

This code works with nearly all preprocessors, but iIt does not work with PGI internal preprocessor (produces “call PREFIX_foo”). Is there a way to do what I need with PGI Fortran preprocessor or the only option is to preprocess the file with a separate pass?

Preprocessing: pgf90 -Mpreprocess -E x.F


Hi Dima,

I have filed this issue with our developers as TPR #20531.

In the meantime, you can work around this issue by preprocessing the file using a separate pass with cpp.

Best regards,