Re: Forward declarations

From: Jake Montgomery (jacobmdrop_nospamers_at_yahoo.com)
Date: 05/13/04


Date: Thu, 13 May 2004 13:47:52 GMT

Marcin Kalicinski wrote:
> Hi All,
>
> In some headers meant to work with both C and C++ the following is often
> found:
>
> typedef struct tagMyStruct { /*some members*/ } MyStruct;
>
> Can I forward-declare MyStruct somehow?
        
    Yes:
        struct tagMyStruct;
    should work.

>
> Or more generally, can I forward declare a typedef or an enum? Also, is

   The lack of a forward declaration of enum is my pet peeve also.
VC6.0,7.0 & 7.1 all support it as a language extension, and it was only
when I began writing cross platform code that I discovered that it was
not legal in c/c++. (It can help immensely in avoiding header spaghetti)
   I realize there are issues regarding knowing the underlying type of
an enum, but if these compilers can handle it, then it is clearly
possible. Nonetheless, I am not holding my breath.

[Snip]
> best regards,
> Marcin

>