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)
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):
$ 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
$