View Source

h3. What are the basic rules for setting the right includes for a file?

Suppose I have a class {{ChromaticGadget}} that extends {{Gadget}} and uses OS
facilities. So I have {{chromaticGadget.hpp}} and {{chromaticGadget.cpp}}. What should
go in {{includeDB}}? In particular when do you have an entry for a .hpp vs.
.cpp file, i.e. should I have:

{code}
chromaticGadget.cpp chromaticGadget.hpp
chromaticGadget.cpp gadget.hpp
chromaticGadget.cpp os.hpp
{code}

or:

{code}
chromaticGadget.cpp chromaticGadget.hpp

chromaticGadget.hpp gadget.hpp
chromaticGadget.hpp os.hpp
{code}

_Answer:_

To reduce compile times, the fewer .hpp files on the left hand side,
the better. So the first example is preferred except ... since you
inherit from {{Gadget}} (which presumably is declared in {{gadget.hpp}}),
I expect you'll have to change the second line in that stanza to

{code}
chromaticGadget.hpp gadget.hpp
{code}

The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact