Archived

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

Nullio

Another Linking/compileing Questions

Recommended Posts

Nullio    122
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
Fruny    1658
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
Kwizatz    1392
"#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
Kylotan    10008
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