On Jan 20, 2006, at 2:24 PM, Eric Albert wrote: On Jan 20, 2006, at 2:16 PM, Dirk Stegemann wrote:
Am 20.01.2006 um 23:24 schrieb Chris Espinosa:
'2' is an integer literal, and only combinations of [ulUL] are allowed for integer literals. '2' is an invalid floating literal, as it has neither a fraction part nor an exponent. It cannot be typed as a float with "F" because it is not a floating literal.
Use 2.F or 2.0F instead.
You're right, and those variants work fine. But the problem isn't that {float f = 2f;} compiles or doesn't compile, but that it behaves differently dependent on the -arch flag.
I still can't reproduce this.
ealbert4:~> cat test.c #import <stdio.h>
int main(int argc, char *argv[]) { float f = 2F; return 0; } ealbert4:~> gcc -v Using built-in specs. Target: powerpc-apple-darwin8 Configured with: /private/var/tmp/gcc/gcc-5250.obj~10/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --target=powerpc-apple-darwin8 Thread model: posix gcc version 4.0.1 (Apple Computer, Inc. build 5250) ealbert4:~> gcc -arch ppc -Wall -g -o test test.c test.c:4:12: error: invalid suffix "F" on integer constant test.c: In function 'main': test.c:4: warning: unused variable 'f' ealbert4:~> gcc -arch i386 -Wall -g -o test test.c test.c:4:12: error: invalid suffix "F" on integer constant test.c: In function 'main': test.c:4: warning: unused variable 'f' ealbert4:~>
When invoked from Xcode, the compile does not fail for Intel:
CompileC build/FakeMain.build/Debug/FakeMain.build/Objects-normal/i386/main.o /Volumes/Local/Projects/Test/FakeMain/main.cpp normal i386 c++ com.apple.compilers.gcc.4_0 cd /Volumes/Local/Projects/Test/FakeMain /usr/bin/gcc-4.0 -x c++ -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -g -O0 -fwritable-strings -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -fvisibility-inlines-hidden -mfix-and-continue -Wno-invalid-offsetof -mmacosx-version-min=10.4 -I/Volumes/Local/Projects/Test/FakeMain/build/FakeMain.build/Debug/FakeMain.build/FakeMain.hmap -F/Volumes/Local/Projects/Test/FakeMain/build/Debug -I/Volumes/Local/Projects/Test/FakeMain/build/Debug/include -I/Volumes/Local/Projects/Test/FakeMain/build/FakeMain.build/Debug/FakeMain.build/DerivedSources -v -x -isysroot /Developer/SDKs/MacOSX10.4u.sdk -dD -c /Volumes/Local/Projects/Test/FakeMain/main.cpp -o /Volumes/Local/Projects/Test/FakeMain/build/FakeMain.build/Debug/FakeMain.build/Objects-normal/i386/main.o Using built-in specs. Target: i686-apple-darwin8 Configured with: /private/var/tmp/gcc/gcc-5247.obj~22/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --build=powerpc-apple-darwin8 --enable-werror-always --with-arch=pentium-m --with-tune=prescott --program-prefix=i686-apple-darwin8- --host=powerpc-apple-darwin8 --target=i686-apple-darwin8 Thread model: posix gcc version 4.0.1 (Apple Computer, Inc. build 5247)
Bizarrely enough, the compiler flag that causes this to fail in Xcode and not in a simple command-line invocation is -fasm-blocks:
[~] cde% /usr/bin/gcc-4.0 -arch i386 -fasm-blocks -c test.cpp -o test.o [~] cde% [~] cde% /usr/bin/gcc-4.0 -arch i386 -c test.cpp -o test.o test.cpp:4:19: error: invalid suffix "F" on integer constant [~] cde%
If you uncheck "CodeWarrior-Style Inline Assembly" in your target build settings, you get the errors on both sides, as expected.
Please note this in the bug report.
Chris |