Click here to Skip to main content
14,639,265 members
Home » Discussions » C / C++ / MFC

C / C++ / MFC

RantC++ Typedefs Pin
nitrous_00729-Jan-19 4:45
Membernitrous_00729-Jan-19 4:45 
GeneralRe: C++ Typedefs Pin
Richard MacCutchan29-Jan-19 5:41
mveRichard MacCutchan29-Jan-19 5:41 
GeneralRe: C++ Typedefs Pin
David Crow29-Jan-19 6:20
MemberDavid Crow29-Jan-19 6:20 
GeneralRe: C++ Typedefs Pin
Joe Woodbury29-Jan-19 9:45
professionalJoe Woodbury29-Jan-19 9:45 
GeneralRe: C++ Typedefs Pin
CPallini29-Jan-19 10:35
mveCPallini29-Jan-19 10:35 
GeneralRe: C++ Typedefs Pin
Stefan_Lang29-Jan-19 21:16
mveStefan_Lang29-Jan-19 21:16 
GeneralRe: C++ Typedefs Pin
leon de boer30-Jan-19 3:20
Memberleon de boer30-Jan-19 3:20 
QuestionWhere do you place your #includes? Pin
den2k8828-Jan-19 23:49
professionalden2k8828-Jan-19 23:49 
I used to place all my #include directives in the header files, for two reasons:
1) When using C++ I have classes to derive to and from, therefore my derived class must "know" its ancestors;
2) I like to use the header files as indexes of the source files: the information about which dependencies has a module is more useful in the header file, as I don't even have to look at the source code unless there are troubles.

I don't mix and match, so I always put all my #includes in the header file.

Now I'm using plain C for a project and I had to include a bulky header (<windows.h> in this instance) to access an API needed only inside that .c file (the rest of the code doesn't use windows APIs).

This made me doubt about the soundness of the choice of putting all #include directives in the header file: having the inclusions constrained in their own compilation units would speed up compilation time and create more separation between modules; on the other hand complex structures often include dozens of headers and the lower levels would benefit from the inclusions already managed by its dependancies.

What do you think about this issue? How do you normally operate?
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

AnswerRe: Where do you place your #includes? Pin
Daniel Pfeffer29-Jan-19 0:32
professionalDaniel Pfeffer29-Jan-19 0:32 
GeneralRe: Where do you place your #includes? Pin
den2k8829-Jan-19 21:12
professionalden2k8829-Jan-19 21:12 
AnswerRe: Where do you place your #includes? Pin
speedbump9929-Jan-19 2:27
Memberspeedbump9929-Jan-19 2:27 
GeneralRe: Where do you place your #includes? Pin
den2k8829-Jan-19 21:10
professionalden2k8829-Jan-19 21:10 
GeneralRe: Where do you place your #includes? Pin
Klaus-Werner Konrad24-Apr-19 4:31
MemberKlaus-Werner Konrad24-Apr-19 4:31 
AnswerRe: Where do you place your #includes? Pin
CPallini29-Jan-19 10:49
mveCPallini29-Jan-19 10:49 
GeneralRe: Where do you place your #includes? Pin
den2k8829-Jan-19 21:07
professionalden2k8829-Jan-19 21:07 
GeneralRe: Where do you place your #includes? Pin
CPallini29-Jan-19 22:07
mveCPallini29-Jan-19 22:07 
AnswerRe: Where do you place your #includes? Pin
Stefan_Lang29-Jan-19 22:28
mveStefan_Lang29-Jan-19 22:28 
AnswerRe: Where do you place your #includes? Pin
leon de boer30-Jan-19 2:26
Memberleon de boer30-Jan-19 2:26 
QuestionPf Pin
Member 1412898028-Jan-19 8:25
MemberMember 1412898028-Jan-19 8:25 
AnswerRe: Pf Pin
CPallini28-Jan-19 9:20
mveCPallini28-Jan-19 9:20 
QuestionWin API or other? Pin
chipp_zanuff26-Jan-19 5:12
Memberchipp_zanuff26-Jan-19 5:12 
AnswerRe: Win API or other? Pin
Victor Nijegorodov26-Jan-19 5:33
MemberVictor Nijegorodov26-Jan-19 5:33 
AnswerRe: Win API or other? Pin
Joe Woodbury28-Jan-19 12:37
professionalJoe Woodbury28-Jan-19 12:37 
AnswerRe: Win API or other? Pin
leon de boer28-Jan-19 17:07
Memberleon de boer28-Jan-19 17:07 
Questionc++ MS Word Pin
Member 1238494426-Jan-19 5:03
MemberMember 1238494426-Jan-19 5:03 

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.