在 OSX 上编译的 gcc 要求。奇怪的错误信息
在 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
根据 FLTK 邮件列表上的以下帖子 问题是由于我没有使用 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 的特殊之处,这样就不会出现错误。
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.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
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Apple 的 GCC 已扩展为理解
CFString
是一种字符串类型,可以与__attribute__((format_arg(...)))
一起使用(用于提供一些在函数之间传递格式字符串时进行额外的错误检查)。标头中有一个条件,如果编译器不支持该属性,则会尝试禁用该属性的这种使用,但它无法检查 Apple 特定的 GCC。请参阅 http://gcc.gnu.org/bugzilla/show_bug.cgi?id= 44981 - 看起来它现在已经在主线 GCC 中实现了。
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.