Click here to Skip to main content
15,891,204 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Problem in Reading File. Pin
SnowHow16-Jul-10 7:18
SnowHow16-Jul-10 7:18 
GeneralRe: Problem in Reading File. Pin
Shivanand Gupta19-Jul-10 0:10
Shivanand Gupta19-Jul-10 0:10 
QuestionMouse Move Capture Pin
shiv@nand15-Jul-10 19:23
shiv@nand15-Jul-10 19:23 
AnswerRe: Mouse Move Capture Pin
KarstenK15-Jul-10 22:04
mveKarstenK15-Jul-10 22:04 
QuestionProper #include sequence Pin
Trevor Johansen15-Jul-10 15:21
Trevor Johansen15-Jul-10 15:21 
AnswerRe: Proper #include sequence Pin
coder21k15-Jul-10 19:28
coder21k15-Jul-10 19:28 
GeneralRe: Proper #include sequence Pin
Trevor Johansen15-Jul-10 19:54
Trevor Johansen15-Jul-10 19:54 
AnswerRe: Proper #include sequence Pin
Aescleal15-Jul-10 21:23
Aescleal15-Jul-10 21:23 
You're actually doing things a bit backwards - in C and C++ the general rule is to only include the minimum number of other files in headers. You only want declarations included that are actually going to be used by clients of that header. While C isn't as bad as C++ I've seen large (250kloc) projects have their build times cut by a factor of 100 by using these techniques. It also avoids dependency fear - "aaarggghh, I can't change this header as absolutely everything includes it directly or indirectly and everything will build, bollocks, I'll just hack something in this C file to get 'round it..."

Interestingly and generally (this depends on your compiler, most I use work this way) what you include doesn't usually have much effect on the code size. Declarations and macros don't occupy space in an object file - it's definitions that do. Exactly what the linker does depends on the linker (and how the compiler packages functions) but most modern linkers remove multiple definitions of objects with the same name. However some require command line switches to turn this on so it's a good idea to look at your compiler and linker docs and find out what all the switches do. One good rule to follow is that if your compiler is a C++ compiler it'll support multiple definition removal (saves the embarrassment of template explosion on code size), if it's just a C compiler then it may take some fiddling to do so.

Cheers,

Ash
GeneralRe: Proper #include sequence Pin
Trevor Johansen16-Jul-10 21:13
Trevor Johansen16-Jul-10 21:13 
QuestionAllocating memory Pin
ALLERSLIT15-Jul-10 6:31
ALLERSLIT15-Jul-10 6:31 
AnswerRe: Allocating memory Pin
Emilio Garavaglia15-Jul-10 7:24
Emilio Garavaglia15-Jul-10 7:24 
AnswerRe: Allocating memory Pin
elchupathingy15-Jul-10 8:34
elchupathingy15-Jul-10 8:34 
AnswerRe: Allocating memory Pin
Richard MacCutchan15-Jul-10 8:56
mveRichard MacCutchan15-Jul-10 8:56 
GeneralRe: Allocating memory Pin
ALLERSLIT15-Jul-10 13:59
ALLERSLIT15-Jul-10 13:59 
QuestionFind the installed version of MS Word Pin
sashoalm15-Jul-10 4:12
sashoalm15-Jul-10 4:12 
AnswerRe: Find the installed version of MS Word Pin
Code-o-mat15-Jul-10 5:45
Code-o-mat15-Jul-10 5:45 
AnswerRe: Find the installed version of MS Word Pin
Richard MacCutchan15-Jul-10 5:58
mveRichard MacCutchan15-Jul-10 5:58 
AnswerRe: Find the installed version of MS Word Pin
Cool_Dev15-Jul-10 18:44
Cool_Dev15-Jul-10 18:44 
GeneralRe: Find the installed version of MS Word [modified] Pin
enhzflep15-Jul-10 21:39
enhzflep15-Jul-10 21:39 
GeneralRe: Find the installed version of MS Word Pin
sashoalm15-Jul-10 22:16
sashoalm15-Jul-10 22:16 
GeneralRe: Find the installed version of MS Word [modified] Pin
Cool_Dev16-Jul-10 2:22
Cool_Dev16-Jul-10 2:22 
QuestionCreateFile - " file is being used by another process." [modified] Pin
Cvaji15-Jul-10 2:31
Cvaji15-Jul-10 2:31 
AnswerRe: CreateFile - " file is being used by another process." Pin
Niklas L15-Jul-10 2:41
Niklas L15-Jul-10 2:41 
AnswerRe: CreateFile - " file is being used by another process." Pin
Naveen15-Jul-10 3:18
Naveen15-Jul-10 3:18 
GeneralRe: CreateFile - " file is being used by another process." Pin
Cvaji15-Jul-10 3:30
Cvaji15-Jul-10 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.