Click here to Skip to main content
15,881,803 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMessage Closed Pin
16-Feb-15 22:10
mveCPallini16-Feb-15 22:10 
AnswerMessage Closed Pin
16-Feb-15 22:52
professionalOrjan Westin16-Feb-15 22:52 
AnswerRe: Const VS Defines Pin
Orjan Westin16-Feb-15 23:02
professionalOrjan Westin16-Feb-15 23:02 
GeneralRe: Const VS Defines Pin
SoMad17-Feb-15 5:13
professionalSoMad17-Feb-15 5:13 
GeneralRe: Const VS Defines Pin
Albert Holguin17-Feb-15 10:40
professionalAlbert Holguin17-Feb-15 10:40 
GeneralRe: Const VS Defines Pin
Orjan Westin17-Feb-15 23:38
professionalOrjan Westin17-Feb-15 23:38 
AnswerRe: Const VS Defines Pin
Albert Holguin17-Feb-15 10:42
professionalAlbert Holguin17-Feb-15 10:42 
GeneralRe: Const VS Defines Pin
Daniel Pfeffer18-Feb-15 6:13
professionalDaniel Pfeffer18-Feb-15 6:13 
In my experience, very few projects have a requirement that they be compilable as both C and C++. Many libraries must be accessible from both C and C++, but a well-designed C-style interface will take care of that.

For example, instead of:
C++
#define MAX_SIZE 42

write a function,
C++
int GetMaxSize()

which returns the value of the constant from your library.

This has the further advantage of decoupling the library from the constant - any changes to MAX_SIZE won't require the client's code to be recompiled (possibly relinked, if we are talking about a static library).
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.

--Winston Churchill

GeneralRe: Const VS Defines Pin
Albert Holguin18-Feb-15 8:42
professionalAlbert Holguin18-Feb-15 8:42 
GeneralRe: Const VS Defines Pin
Daniel Pfeffer18-Feb-15 21:53
professionalDaniel Pfeffer18-Feb-15 21:53 
GeneralRe: Const VS Defines Pin
Stefan_Lang18-Feb-15 22:22
Stefan_Lang18-Feb-15 22:22 
GeneralRe: Const VS Defines Pin
Daniel Pfeffer18-Feb-15 22:50
professionalDaniel Pfeffer18-Feb-15 22:50 
GeneralRe: Const VS Defines Pin
Stefan_Lang19-Feb-15 0:33
Stefan_Lang19-Feb-15 0:33 
GeneralRe: Const VS Defines Pin
Stefan_Lang18-Feb-15 22:08
Stefan_Lang18-Feb-15 22:08 
AnswerRe: Const VS Defines Pin
den2k8818-Feb-15 22:52
professionalden2k8818-Feb-15 22:52 
QuestionAdd Record in MySQL Pin
Django_Untaken16-Feb-15 3:22
Django_Untaken16-Feb-15 3:22 
AnswerRe: Add Record in MySQL Pin
Richard Andrew x6416-Feb-15 5:25
professionalRichard Andrew x6416-Feb-15 5:25 
AnswerRe: Add Record in MySQL Pin
Jochen Arndt16-Feb-15 6:02
professionalJochen Arndt16-Feb-15 6:02 
Question'RegisterClass' - MS Documentation Error? Pin
Bram van Kampen15-Feb-15 14:39
Bram van Kampen15-Feb-15 14:39 
AnswerRe: 'RegisterClass' - MS Documentation Error? Pin
Richard Andrew x6415-Feb-15 16:28
professionalRichard Andrew x6415-Feb-15 16:28 
GeneralRe: 'RegisterClass' - MS Documentation Error? Pin
Bram van Kampen15-Feb-15 18:17
Bram van Kampen15-Feb-15 18:17 
AnswerRe: 'RegisterClass' - MS Documentation Error? Pin
Daniel Pfeffer15-Feb-15 20:32
professionalDaniel Pfeffer15-Feb-15 20:32 
AnswerRe: 'RegisterClass' - MS Documentation Error? Pin
Richard MacCutchan15-Feb-15 21:54
mveRichard MacCutchan15-Feb-15 21:54 
GeneralRe: 'RegisterClass' - MS Documentation Error? Pin
Bram van Kampen15-Feb-15 22:51
Bram van Kampen15-Feb-15 22:51 
GeneralRe: 'RegisterClass' - MS Documentation Error? Pin
Richard MacCutchan15-Feb-15 23:02
mveRichard MacCutchan15-Feb-15 23:02 

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.