Is it poor form to forward declare everything in its own header file, let's say "forwardDec.hpp" -- then #including that file in every other header file and just including any dependant header files from each of the .cpp files?
forward deceleration
Also known as 'acceleration'.
Name:
Anonymous2012-12-28 2:01
Cudder, is it ok if I do this though?
Name:
Anonymous2012-12-28 2:48
>>5
You should do it, continue using it throughout your large project, and then one month later come back here and submit a four page essay on why it should never be done.
but I think doing this should be fine. Forward declarations are annoying and this gets rid of them. But now every time you declare a data type you have to add its name to the list in forwardDec.hpp. It's still less typing than what you would do with forward declarations though.
>>1,2
Given that the whole point of forward declarations in headers is to eliminate unnecessary dependencies, introducing an extra header file that all compilation units must use seems totally self-defeating. In practice, if you have to change the forward declaration you'll likely have to change all the other headers anyway.
>>15
Or he could use a tool to extract the header information from the sources automatically... I wonder why something like that hasn't been added to C compilers already.