This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fwd: Preprocess files with gcc/gfortran vs. cpp


I am trying to figure out if there is a bug in the preprocessing of
gcc/gfortran while not in cpp.

I am using gcc-5.2.0 with gcc, gfortran and cpp, i.e.
$> which gcc
$> which gfortran
$> which cpp
yields:
/opt/generic/gcc/5.2.0/bin/gcc
/opt/generic/gcc/5.2.0/bin/gfortran
/opt/generic/gcc/5.2.0/bin/cpp

I have also tested with 4.9.2 which yields the same results.

Now I want to try to concatenate several variables together to achieve
a dynamic variable naming scheme of variables, modules etc.
Here is a basic example:

<<< start-of-file
#define A_CC(a,b) A_CCX(a,b)
#define A_CCX(a,b) a ## b
#define A_NEW mod
#define MY_MOD A_CC(A_NEW,_hello)
program MY_MOD
  integer :: t
  t = 2
  print *, t
end program
<<< end-of-file

Now if I do:
$> cpp -E -P -nostdinc
program mod_hello
  integer :: t
  t = 2
  print *, t
end program

which is the expected result.
Doing the same with gcc/gfortran yields
$> gcc -P -E -nostdinc
program mod ## _hello
  integer :: t
  t = 2
  print *, t
end program

Am I missing some point here?
I would have expected gcc/gfortran to use the _same_ preprocessing
utility as that provided in cpp?

I do require a double nesting of the concatenation to ensure expansion.

--
Kind regards Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]