尝试在OSX 10.6上编译libSDL时出现以下错误消息
/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.framework/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
根据following post on FLTK mailing list,问题是由于我没有使用Apple提供的gcc。的确,我正在使用自己的编译器
$ 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.
这与Apple提供的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.
我很好奇的是两者之间的区别...当然我不希望你知道我的编译器中发生了什么,但我希望有人知道Apple gcc中的特殊之处,以便错误没有出现。
答案 0 :(得分:0)
Apple的GCC已经扩展到了解CFString
是一种可以与__attribute__((format_arg(...)))
一起使用的字符串类型(用于在函数之间传递格式字符串时提供一些额外的错误检查)。如果编译器不支持该属性,则标头中有一个条件尝试禁用该属性的使用,但它无法检查Apple特定的GCC。
请参阅http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44981 - 现在看来它已在主线GCC中实施。