Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Development and Darwin (http://www.mac-forums.com/forums/os-x-development-darwin/)
-   -   Carbon, n00b problem :) (http://www.mac-forums.com/forums/os-x-development-darwin/57636-carbon-n00b-problem.html)

jaysonturner 03-27-2007 03:58 PM

Carbon, n00b problem :)
 
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 :)

musicforme 04-02-2007 12:35 PM

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.

macmini3399 04-03-2007 10:30 PM

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;
}


All times are GMT -4. The time now is 02:26 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.