Checking if integer is even or not

Started by
12 comments, last by GameDev.net 18 years, 1 month ago
Quote:Original post by jyk
I don't know if this is standard, but in my experience all caps is usually reserved for macros, enums, and constants. I just mention it because it might make calls to the above functions look a little misleading.


It would be really unwise to change from ALLCAPS because if for some reason there were a lot of #define macros and some of them were converted to inline procs then trying to remember if certain functions changed their names can be error prone.

Besides, inline procs can be considered macros because the compiler will just insert the code where you invocated the function, just like a #define macro
Advertisement
Quote:Original post by Adam Hamilton
Quote:Original post by jyk
I don't know if this is standard, but in my experience all caps is usually reserved for macros, enums, and constants. I just mention it because it might make calls to the above functions look a little misleading.


It would be really unwise to change from ALLCAPS because if for some reason there were a lot of #define macros and some of them were converted to inline procs then trying to remember if certain functions changed their names can be error prone.

Besides, inline procs can be considered macros because the compiler will just insert the code where you invocated the function, just like a #define macro


jyk is right. Inline functions shouldn't be considered macros. The preprocessor performs macro token substitution which is different than what happens with an inline function.

This substitution happens before the compiler parses the code.

[Edited by - LessBread on March 16, 2006 7:32:54 PM]
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
You are right LessBread, macros are different from inline procs in the way a preprocessor handles them but I am right in that you shouldn't change from CHECKEVEN to CheckEven. It is error prone.
Quote:Original post by Adam Hamilton
You are right LessBread, macros are different from inline procs in the way a preprocessor handles them but I am right in that you shouldn't change from CHECKEVEN to CheckEven. It is error prone.


Right, but for the wrong reasons. A common convention is to use ALL_CAPS for macros that may evaluate their arguments more than once but use theFunctionConvention/the_function_convetion/etc. for "function-like macros" (i.e. macros that evaluate their arguments only once). The main reason for ALL_CAPS macros is to say "this may not do what you expect it to".

I would prefer the change for consistency. But, then again, what do I know, I'm an AP. [grin]

This topic is closed to new replies.

Advertisement