Preprocessor concatenation

Steve Kargl sgk@troutmask.apl.washington.edu
Mon Feb 8 23:52:00 GMT 2016


On Mon, Feb 08, 2016 at 11:52:31PM +0100, Alberto Luaces wrote:
> 
> is there any way of writing a concatenation macro when using the
> preprocessor?  It only works with the "traditional" style
> 
> #define paste(x,y) x/**/y
> 
> but I wanted it to work with ## in order to be compatible with other
> compilers.
> 

>From the gfortran documentation: "In the case of GNU Fortran, this isr
the GNU C Preprocessor in the traditional mode."

So, the answer to your question is

#ifdef __GFORTRAN__
#define paste(x,y) x/**/y
#else
#define paste(x,y) x ## y
#endif

-- 
Steve



More information about the Fortran mailing list