Carbon, n00b problem :)

Joined
Mar 27, 2007
Messages
3
Reaction score
1
Points
3
Your Mac's Specs
MacBook 2Ghz Core2Duo
Hi,

Thought I'd have a bash at a bit of Carbon today, but Xcode keeps moaning. Ive made this simple program to print the current time.

Code:
#include <stdio.h>
#include <CoreFoundation/CoreFoundation.h>

int main (int argc, const char * argv[]) {
	
	CFAbsoluteTime time;
	time = CFAbsoluteTimeGetCurrent();
	
	printf("%d", time);
    return 0;
}

Now, with ZeroLink on, i get this error at runtime.

ZeroLink: unknown symbol '_CFAbsoluteTimeGetCurrent'
Test has exited due to signal 6 (SIGABRT).


But with ZeroLink off, i get

Undefined symbols:
_CFAbsoluteTimeGetCurrent

at compile time...

I've obviously missed something, any help would be nice :)
 
Joined
Mar 20, 2007
Messages
22
Reaction score
0
Points
1
Location
Grapevine, Tx
Your Mac's Specs
Early 2008 Mac Pro - 500 GB HD - 6 GB Ram
I've never programmed in this language, but have some experience in VB.net and Java.

I wonder if time = CFAbsoluteTimeGetCurrent() shouldn't be time = CFAbsoluteTime.GetCurrent()

Note the extra period between what is probably the Object class and the method.
 
Joined
Nov 25, 2005
Messages
234
Reaction score
6
Points
18
Location
Nova Scotia
Your Mac's Specs
Intel Core solo Mac mini 1.5GHz, Headless Powerbook G4 500MHz
Hey. CoreFoundation is not Object-Oriented, its procedural. It should go like this:

#import <Carbon/Carbon.h>

int main (int argc, const char * argv[])
{
printf("%d\n", (double)CFAbsoluteTimeGetCurrent());
return 0;
}
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top