M
Marcin Kalicinski
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?
Or more generally, can I forward declare a typedef or an enum? Also, is
there any reason why there should be difference between forward declarations
of classes and structs (i.e. why I need to explicitly write keyword 'struct'
or 'class' when forward declaring). In some cases I don't immediately know
what to write, because, for example, the type definition in original header
file is generated with some macro, such as this:
STDINTERFACE(IBlahBlah, IBaseBlahBlah) {
/* Members */
}
Now I need to search for the definition of STDINTERFACE to see how it works.
Even if I find it, it still may silently change in some future version of
the header file, and cause my compilation to fail. Wouldn't allowing a
generic form of forward declaration, without introducing a new keyword:
typename IBlahBlah;
be beneficial to C++?
best regards,
Marcin
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?
Or more generally, can I forward declare a typedef or an enum? Also, is
there any reason why there should be difference between forward declarations
of classes and structs (i.e. why I need to explicitly write keyword 'struct'
or 'class' when forward declaring). In some cases I don't immediately know
what to write, because, for example, the type definition in original header
file is generated with some macro, such as this:
STDINTERFACE(IBlahBlah, IBaseBlahBlah) {
/* Members */
}
Now I need to search for the definition of STDINTERFACE to see how it works.
Even if I find it, it still may silently change in some future version of
the header file, and cause my compilation to fail. Wouldn't allowing a
generic form of forward declaration, without introducing a new keyword:
typename IBlahBlah;
be beneficial to C++?
best regards,
Marcin