gcc requirements to compile on OSX. Strange error message
I get the following error message while trying to compile libSDL on OSX 10.6
/bin/sh ./libtool --mode=compile gcc -g -O2 -I./include -D_GNU_SOURCE=1 -DTARGET_API_MAC_CARBON -DTARGET_API_MAC_OSX -fvisibility=hidden -I/usr/X11R6/include -DXTHREADS -D_THREAD_SAFE -force_cpusubtype_ALL -c ./src/audio/macosx/SDL_coreaudio.c -o build/SDL_coreaudio.lo
libtool: compile: gcc -g -O2 -I./include -D_GNU_SOURCE=1 -DTARGET_API_MAC_CARBON -DTARGET_API_MAC_OSX -fvisibility=hidden -I/usr/X11R6/include -DXTHREADS -D_THREAD_SAFE -force_cpusubtype_ALL -c ./src/audio/macosx/SDL_coreaudio.c -fno-common -DPIC -o build/.libs/SDL_coreaudio.o
In file included from /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:43,
from /System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:83,
from /System/Library/Frameworks/CoreAudio.framewo开发者_开发百科rk/Headers/CoreAudio.h:19,
from ./src/audio/macosx/SDL_coreaudio.c:24:
/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBundle.h:147:
error: format string argument not a string type
make: *** [build/SDL_coreaudio.lo] Error 1
According to the following post on FLTK mailing list the problem is due to the fact that I am not using Apple provided gcc. Indeed I am using my own compiler
$ gcc --version
gcc (GCC) 4.3.4
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Which is different from the Apple provided gcc:
/usr/bin/gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
What I am curious about is the difference between the two... Of course I don't expect you to know what's going on in my compiler, but I would expect someone knows what's special in the Apple gcc so that the error does not arise.
Apple's GCC has been extended to understand that CFString
is a string type that can be used with __attribute__((format_arg(...)))
(which is used to provide some extra error-checking when format strings are passed between functions). There is a conditional in the header which tries to disable this usage of the attribute if the compiler doesn't support it, but it fails to check for Apple-specific GCC.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44981 - it looks like it has now been implemented in mainline GCC.
精彩评论