A good way to make sure all headers aren't missing any include or forward-declaration that really is needed, is to make each .cpp include its corresponding .h *first*.
For example, proxy_info.cpp currently includes parse.h and error_numbers.h, and *then* includes proxy_info.h. But if it was including proxy_info.h before anything else, you would have noticed that it's missing a XML_PARSER forward declaration, because proxy_info.cpp wouldn't compile otherwise. (A visual inspection also shows that it's unnecessarily including miofile.h when a MIOFILE forward-declaration would suffice) -- Nicolás 2012/7/30 David Anderson <[email protected]>: > Another convention: > when foo.h contains fields of type pointer to BLAH, > it doesn't include blah.h; > instead it declares > struct BLAH; > at the top. > > foo.h needs to include blah.h only if it contains fields of type BLAH, > or otherwise needs to refer to the internals of BLAH. > > -- David > > On 30-Jul-2012 12:55 PM, [email protected] wrote: >> >> I agree with including headers only in the files that need them. However, >> some headers need to include other headers. Specifically where Header A >> uses a class or structure defined in Header B. In that case, Header A >> needs to include Header B. I have been on many chases trying to figure out >> why something just will not compile and discovering that the order of >> header includes changed someplace which made the definition of a class >> happen after its first use. So the apparent law that headers should only >> be included in cpp files is a bit too strong. >> >> jm7 _______________________________________________ boinc_dev mailing list [email protected] http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev To unsubscribe, visit the above URL and (near bottom of page) enter your email address.
