g++在 Mac OS X 上 - CoreServices.h 错误
当我使用 g++
编译以下代码时,
#include <CoreServices/CoreServices.h>
int main(int argc, char ** argv)
{
return 0;
}
出现此错误。
bash-3.2$ g++ test.C
In file included from /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:43:0,
from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:20,
from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20,
from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21,
from test.C:1:
/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBundle.h:147:120: error: format string argument not a string type
有谁知道我能做些什么来让它发挥作用?我正在尝试使用 mach_absolute_time
和 AbsoluteToNanoseconds
,它位于 CoreServices.h
中,例如 此处。
g++ -v
gcc version 4.5.0 20100107 (experimental) (GCC)
When I compile the following code with g++
#include <CoreServices/CoreServices.h>
int main(int argc, char ** argv)
{
return 0;
}
I get this error.
bash-3.2$ g++ test.C
In file included from /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:43:0,
from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:20,
from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20,
from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21,
from test.C:1:
/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBundle.h:147:120: error: format string argument not a string type
Does anyone know what I can do to get it to work? I am trying to use mach_absolute_time
and AbsoluteToNanoseconds
, which is in CoreServices.h
, like here.
g++ -v
gcc version 4.5.0 20100107 (experimental) (GCC)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您正在尝试使用 Apple 的框架而不使用 Apple 的工具链 - 这可能行不通。您的示例程序在这里对我来说编译得很好,使用 Xcode(和 clang)附带的 gcc:
It looks like you're trying to use Apple's frameworks without using Apple's toolchain - that's probably not going to work. Your example program compiles fine here for me, using the gcc that came with Xcode (and with clang):