Preprocessor concatenation
Alberto Luaces
aluaces@udc.es
Tue Feb 9 08:48:00 GMT 2016
Steve Kargl writes:
> 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."
>
Yes, that is what I also read from the documentation...
>
> So, the answer to your question is
>
> #ifdef __GFORTRAN__
> #define paste(x,y) x/**/y
> #else
> #define paste(x,y) x ## y
> #endif
...but I did not realize that the solution could be so simple; I was
over-thinking it, and fearing that I would have to write some tests on
my build system.
Thank you, Steve.
--
Alberto
More information about the Fortran
mailing list