undefining a typedef

Stan Brown, Oak Road Systems browns at astro.pc.ab.com
Sun Aug 12 04:06:16 AEST 1990


In article <1820006 at hpsad.HP.COM>, jose at hpsad.HP.COM (Jose Gomez-Rubio (SEED Student)) writes:
> How does one undefine a typedef construction in a header file?
> 
> The problem is that a specific typedef construction is declared
> unconditionally in 3 separate header files in a source file that includes
> those 3 specific header files.
> 
> I've tried #ifndef foobar ... #endif and #if !defined (foobar) ... #endif
> to no avail.  The compiler still complains about redefinition of typedef
> and refuses to continue. 

I don't have a good solution, but I can help explain the problem.  #ifdef and
#if defined()--which is really the same thing--ask whether PREPROCESSOR symbols
are defined; i.e. whether the symbols have been #defined.  A typedef is not a
preprocessor symbol.

What I do in these cases is something like this:
   #ifndef TYPE_MUMBLE_DEFINED
   typedef char *MUMBLE[ ];
   #define TYPE_MUMBLE_DEFINED 1
   #endif
It's ugly, and I'd love to hear a better way.

Stan Brown, Oak Road Systems, (216) 371-0043
The opinions expressed are mine. Mine alone!  Nobody else is responsible for
them or even endorses them--except my cat Dexter, and he signed the power of
attorney only under my threat to cut off his Cat Chow!



More information about the Comp.lang.c mailing list