Re: Function definitions
Re: Function definitions
- Subject: Re: Function definitions
- From: Ondra Cada <email@hidden>
- Date: Sun, 9 Apr 2006 01:24:00 +0200
Robert,
On 9.4.2006, at 1:00, Robert Martin wrote:
It's declared in the header so that other files can reference it by
including the header. It's defined in the implementation file so
the compiler can map the code it generates to the function's name.
Hard to figure out a simpler way of getting this done.
Well... there of course *is* simpler (but error-prone, thus not used
in practice) way: not using the declarations at all, since other
files *do not* need the declaration for referencing.
Try this:
4 /tmp> >q.m
int sum(int a,int b) { return a+b; }
5 /tmp> >w.m
#import <Cocoa/Cocoa.h>
int main() { printf("wow! %d\n",sum(5,5)); return 0; }
6 /tmp> cc q.m w.m && ./a.out
wow! 10
7 /tmp>
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden