[comp.sys.mac.programmer] THINK C: Trouble with multiply #included files

rabbit@eddie.mit.edu (Warren J. Madden) (04/15/91)

Greetings, netfolk.

	I have been working on a program in THINK C 4.0.2, and have
encountered a problem with several include files I'm using.  The manual
says (in reference to TCL header files) that if you want a file to only be
included once, #define _H_filename, where filename is the name of the
include file.  I attempted to do this with other include files, but started
getting multiply declared variable problems popping up at link time.

	Does this feature only work with TCL header files?  What is the
means by which it is implemented?  Right now I'm working around the problem
by emulating the feature using #ifdef, but I'd like to know if I should be
doing it some other way.


Thanx in advance,

Warren J. Madden
rabbit@eddie.mit.edu

ech@cbnewsk.att.com (ned.horvath) (04/17/91)

From article <1991Apr15.002722.18346@eddie.mit.edu>, by rabbit@eddie.mit.edu (Warren J. Madden):

> Greetings, netfolk.

> 	I have been working on a program in THINK C 4.0.2, and have
> encountered a problem with several include files I'm using.  The manual
> says (in reference to TCL header files) that if you want a file to only be
> included once, #define _H_filename, where filename is the name of the
> include file.  I attempted to do this with other include files, but started
> getting multiply declared variable problems popping up at link time.

The _H_name is case sensitive.  Make sure all the #include "name.h" lines
EXACTLY match the spelling in #define _H_name.

Yes, I got bit by this too...

=Ned Horvath=
ehorvath@attmail.com

upstill@pixar.com () (04/26/91)

Also beware the fact that the _H_ feature doesn't care much for 
punctuation. At least including the line

#define _H_Pkg.foo

in file "Pkg.foo.h" does nothing to prevent multiple loading in

#include "Pkg.foo.h"
#include "Pkg.foo.h"

...to my regret, I must say.

Steve Upstill