Click here to Skip to main content
15,887,355 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Local / unique Variable Macro question Pin
Iain Clarke, Warrior Programmer18-Jun-17 20:36
Iain Clarke, Warrior Programmer18-Jun-17 20:36 
SuggestionRe: Local / unique Variable Macro question Pin
Jochen Arndt18-Jun-17 21:42
professionalJochen Arndt18-Jun-17 21:42 
AnswerRe: Local / unique Variable Macro question Pin
leon de boer19-Jun-17 3:40
leon de boer19-Jun-17 3:40 
GeneralRe: Local / unique Variable Macro question Pin
ForNow19-Jun-17 3:55
ForNow19-Jun-17 3:55 
GeneralRe: Local / unique Variable Macro question Pin
leon de boer19-Jun-17 5:14
leon de boer19-Jun-17 5:14 
GeneralRe: Local / unique Variable Macro question Pin
ForNow19-Jun-17 5:52
ForNow19-Jun-17 5:52 
GeneralRe: Local / unique Variable Macro question Pin
leon de boer19-Jun-17 9:16
leon de boer19-Jun-17 9:16 
AnswerRe: Local / unique Variable Macro question Pin
Bram van Kampen28-Jun-17 13:21
Bram van Kampen28-Jun-17 13:21 
Well,

You tell me that it does not compile, you don't say what errors are thrown up.

Your concept of a Macro makes your code often easier to read and follow (Very Important for Maintenance) However, a Macro can be very tricky to write. For one, the Debugger cannot get a grip on it. That is because a macro is resolved in the Pre-Compiler, at a Text Translation Level, essentially before the C(PP) compiler gets a grip on your code. It does no longer see your macro code, so, you get obscure errors if you don't have the macro perfectly correct, and, not where the Macro is declared, but where you implement it.

The Book by Kernigan and Ritchie: 'The C Language' explains the process concisely.

I often start with writing a complicated Macro as a Function, debug it, and strip it out into a macro.
Do Not forget the trivial things, e.g. a Line Break ( '\') as the VERY LAST char on a line in the file, before the Newline. (if spaces follow the '\' before the NewLine, it will not be read correctly).

There are horses for courses. It has mainly to do with readability and convenience. Modern Compilers are very smart on optimisation, and will nearly always isolate repeated code into a single function in the retail version. (It typically does not do such optimisation in the Debug version) Space was a literally crunching issue in 16 bit programming, a nearly unimportant issue in 32 bit, and, (for now) essentially a non issue in 64 bit.

Now, sometimes such optimisation is specifically not wanted. You can get out of this by declaring a variable or function as 'volatile', in which case the compiler lays out the code exactly as you wrote it.

Regards, Smile | :)
Bram van Kampen

GeneralRe: Local / unique Variable Macro question Pin
ForNow28-Jun-17 13:47
ForNow28-Jun-17 13:47 
GeneralRe: Local / unique Variable Macro question Pin
Bram van Kampen28-Jun-17 14:21
Bram van Kampen28-Jun-17 14:21 
QuestionDisecting a PE File Pin
Bram van Kampen16-Jun-17 14:19
Bram van Kampen16-Jun-17 14:19 
AnswerRe: Disecting a PE File Pin
leon de boer17-Jun-17 3:17
leon de boer17-Jun-17 3:17 
GeneralRe: Disecting a PE File Pin
Bram van Kampen18-Jun-17 12:46
Bram van Kampen18-Jun-17 12:46 
GeneralRe: Disecting a PE File Pin
harold aptroot18-Jun-17 3:11
harold aptroot18-Jun-17 3:11 
GeneralRe: Disecting a PE File Pin
Bram van Kampen18-Jun-17 13:05
Bram van Kampen18-Jun-17 13:05 
GeneralRe: Disecting a PE File Pin
harold aptroot18-Jun-17 13:39
harold aptroot18-Jun-17 13:39 
GeneralRe: Disecting a PE File Pin
Bram van Kampen19-Jun-17 13:27
Bram van Kampen19-Jun-17 13:27 
GeneralRe: Disecting a PE File Pin
harold aptroot19-Jun-17 14:27
harold aptroot19-Jun-17 14:27 
GeneralRe: Disecting a PE File Pin
Richard MacCutchan19-Jun-17 20:57
mveRichard MacCutchan19-Jun-17 20:57 
GeneralRe: Disecting a PE File Pin
Bram van Kampen29-Jun-17 12:00
Bram van Kampen29-Jun-17 12:00 
GeneralRe: Disecting a PE File Pin
Richard MacCutchan29-Jun-17 21:28
mveRichard MacCutchan29-Jun-17 21:28 
GeneralRe: Disecting a PE File Pin
Bram van Kampen30-Jun-17 14:19
Bram van Kampen30-Jun-17 14:19 
GeneralRe: Disecting a PE File Pin
Richard MacCutchan30-Jun-17 21:30
mveRichard MacCutchan30-Jun-17 21:30 
GeneralRe: Disecting a PE File Pin
Bram van Kampen2-Jul-17 13:26
Bram van Kampen2-Jul-17 13:26 
GeneralRe: Disecting a PE File Pin
Richard MacCutchan2-Jul-17 21:42
mveRichard MacCutchan2-Jul-17 21:42 

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.