• Advertisement

Archived

This topic is now archived and is closed to further replies.

Another Linking/compileing Questions

This topic is 5972 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you people manage projects with many files in them so they all have the proper #include statements to work properly and don''t cause any linking errors?

Share this post


Link to post
Share on other sites
Advertisement
With discipline (no kidding). Knowing the purpose of the each #include helps too. As well as using forward declarations to avoid header inclusion recursion.

AFAIK, there is no other secret.

Share this post


Link to post
Share on other sites
"#include statements" dont cause linking errors, they cause compiling errors

for inclusion-recursion you just have to put

#ifndef MYHEADER_H
#define MYHEADER_H

at the top of your header file (replacing "MYHEADER" for say, the filename of the header) then write all your prototypes and declarations, at the end you add

#endif // MYHEADER_H

other than that not including a header, including the header but not the lib (which by the way is what causes linking errors), not setting an alternate include or lib path in cases where it is required is what causes compilation and llinking problems

Share this post


Link to post
Share on other sites
And don''t instantiate any variables or functions in the headers: just give class definitions, constants, #defines, extern references to variables, and function prototypes.

Share this post


Link to post
Share on other sites

  • Advertisement