Re: Circular references
Re: Circular references
- Subject: Re: Circular references
- From: Jay Reynolds Freeman <email@hidden>
- Date: Sun, 13 Sep 2009 15:31:16 -0700
A classic (but non-traditionally-Cocoa) way to deal with this problem
is with #ifndef preprocessor statements. You make up a preprocessor
symbol for each include file -- I often use the include-file name in
all capitals, with some "__"s bracketing it. Then you use it as
follows. Suppose you have a header file called "foo.h" with some
simple stuff in it. Here is what the text of "foo.h" might be:
######## SNIP ########
// foo.h, copyright whoever whenever
#ifndef __FOO_H__
#define __FOO_H__
#import bar.h
#import baz.h
extern int whatever();
// ... more statements to your liking.
#endif
######## SNIP ########
This mechanism ensures that the statements inside the #ifndef ...
#endif will be included only once in any file that goes through the
preprocessor.
-- Jay Reynolds Freeman
---------------------
email@hidden
http://web.mac.com/jay_reynolds_freeman (personal web site)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden