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
---------------------
jay_reynolds_free...@mac.com
http://web.mac.com/jay_reynolds_freeman (personal web site)

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to