Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334882

Summary: C Preprocessing of String Literals Differs from gfortran
Product: [Tools] PTP Reporter: Matthew Fotzler <incongruous>
Component: Photran.For Internal UseAssignee: Photran Inbox <photran-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P5 CC: com-eclipse-dot-org
Version: 6.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Matthew Fotzler CLA 2011-01-20 08:56:34 EST
The following program:

#define GREAT(X) "X is the greatest!"

program test

	print *, GREAT(Photran)

end program

produces the following when preprocessed by Photran/GCC/NAG

program test

 print *, "X is the greatest!"

end program

but gfortran produces

program test

	print *, "Photran is the greatest!"

end program

Another strange thing is if I run `cpp`, the gnu c preprocessor, the output matches gfortran's, no matter which standard(c89, c99, c++98, etc.) I use with the -std option.  gcc and cpp both have the same version "i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)", so it's odd that gcc isn't using cpp.
Comment 1 Matthew Fotzler CLA 2011-01-20 09:59:32 EST
Seems to be an issue of traditional C vs. ANSI/ISO C.  With `gcc -E -Wtraditional`, there is the warning "pretest.c:1:18: warning: macro argument "X" would be stringified in traditional C"