当我用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
和here中的AbsoluteToNanoseconds
和CoreServices.h
。g++ -v
gcc version 4.5.0 20100107 (experimental) (GCC)
最佳答案
看来您正在尝试使用Apple的框架而不使用Apple的工具链-这可能行不通。您的示例程序可以使用Xcode(和clang)随附的gcc在这里对我进行编译:
$ cat example.cpp
#include <CoreServices/CoreServices.h>
int main(int argc, char ** argv)
{
return 0;
}
$ make example
g++ example.cpp -o example
$ rm example
$ CXX=clang make example
clang example.cpp -o example
$