Newsgroups: comp.lang.fortran
From: "James Van Buskirk" <not_va...@comcast.net>
Date: Mon, 5 May 2008 12:32:08 -0600
Local: Mon, May 5 2008 2:32 pm
Subject: C preprocessor
I was trying to use the C preprocessor for a Fortran program and it
gave me some insight as to why they are always so out of sorts on comp.lang.c: C:\gfortran\clf\cpp>type cpp.f90 module mod2 program test x = 3 C:\gfortran\clf\cpp>gfortran -x f95-cpp-input -D SYMBOL_1=BESSEL_J0 character(*), parameter :: name = #BESSEL_J0 I found the -x f95-cpp-input command-line option at http://gcc.gnu.org/onlinedocs/gfortran/Preprocessing-and-conditional-... And at http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preproces... the -D name=#BESSEL_J0 option. At http://en.wikipedia.org/wiki/C_preprocessor#Quoting_macro_arguments we find that #BESSEL_J0 should be replaced by "BESSEL_J0" but C:\gfortran\clf\cpp>ifort /Qcpp -D SYMBOL_1=ERFC cpp.f90 cpp.f90(9) : Error: Invalid radix or character in constant out of radix Now we can work around this for gfortran as follows: C:\gfortran\clf\cpp>type cpp1.f90 module mod2 program test x = 3 C:\gfortran\clf\cpp>gfortran -x f95-cpp-input -D SYMBOL_1=BESSEL_J0 C:\gfortran\clf\cpp>cpp1 But ifort's preprocessor is smart enough to grok a free-form character C:\gfortran\clf\cpp>ifort /Qcpp -D SYMBOL_1=ERFC cpp1.f90 Microsoft (R) Incremental Linker Version 8.00.40310.39 -out:cpp1.exe C:\gfortran\clf\cpp>cpp1 So I ultimately abandoned this C preprocessor nonsense and used -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||