Mac Forums

Mac Forums (
-   OS X - Development and Darwin (
-   -   Carbon, n00b problem :) (

jaysonturner 03-27-2007 02:58 PM

Carbon, n00b problem :)

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.


#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:

at compile time...

I've obviously missed something, any help would be nice :)

musicforme 04-02-2007 11:35 AM

I've never programmed in this language, but have some experience in 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 09: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 06:20 PM.

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