Re: [Doxygen-users] Forward declaration of enums
Brought to you by:
dimitri
From: Dan M. <dm...@Cr...> - 2002-01-18 15:37:08
|
A bit of off-topic C++ arcana... Quoting br...@sh...: > In general, you don't want to forward-declare enums. I'm not sure off the top > of my head whether the syntax is even valid; even if it is, you shouldn't use > it. C++ allows the size of an enumerant to depend on the range of values the > enumeration must be able to hold. To derive this information, the compiler must > be able to see the definition of the enumeration in each translation unit where > the enumeration is used. This is a little misleading. Forward declarations never tell the compiler the size of something; that's true for forward class, struct, and enum declarations. They're only useful where you need to mention something by name but don't want to include the full declaration, for instance if you need to specify pointer or reference arguments. This technique is very useful for decoupling header files, keeping build dependencies to a minimum. So forward enum declarations are potentially just as useful in this regard as forward class and struct declarations. Where an enum value, variable, or parameter is used, of course, the compiler does need to see the full declaration. |