http://code-dynasty.net/articles/C_A...ming/83#MacrosOriginally Posted by citizen
http://code-dynasty.net/articles/C_A...ming/83#MacrosOriginally Posted by citizen
Still looking for your point, Desolation.Originally Posted by http://code-dynasty.net/articles/C_And_CPP_Programming/83#Macros
Especially if you make it a global variable.A smart compiler might see that a certain variable is const, never modified (through some obscure technique) and is part of the global namespace and decide to optimize it on its own.
So my choice is just as correct as yours. Macros are also not typesafe, although, this may or may not matter depending on where the macro is used.Therefore, there is hardly any advantage of using either solution.
You seem a mite confused about hex.Originally Posted by Raigne
Google some on it, things like "number system", "hex to decimal tutorial", etc.
Here's a link to start with.
Basically, decimal, the system you use, is base 10. 10 symbols (the numbers 0 to 9) per digit in the number. Hexadecimal is base 16, so 16 symbols per digit in the number, represented by the numbers 0-9 and letters A-F. The above link will show you how to convert between the two.
Hexadecimal, binary, and decimal (among others) are all different ways of representing the same values.
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
Huhh.. I guess I didn't make it obvious that what I wanted to say is that sometimes you shouldn't just base your coding on what people tell you. Some will tell you this or that is a bad habit. Hell, using goto will get you flamed but it has its uses. I never needed it but if I ever feel I need it, I'll use it.Still looking for your point, Desolation.
>> #define JAMES_BOND 007
Hmmm, before some compiler gave me some hassle about prefexing my #define with 0's
having the first character as 0 means you are righting the numer in octo format. So if you did 09 it wouldn't work as there is no symbol 9 in octo.
Yeah it would work.. and yes there is a 9 symbol in octo... 09 would be understood as a base 10 integer and 0x9 is correct.
Why would there be a 9 in octal? It's base eight numbers!
Simple test:Code:int value = 09; /* Error: Illegal octal digit in function main */
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
What utter nonsense. Macros are not properly typed, you cannot take their address, and most of all they're not scoped!any must have heard how "it's better to use const variables than macros" and this is where I say that it's not true. There is really no advantage. The choice is yours. Really.
However, in this particular case macros are probably better, because such definitions are usually within a resource header that is also included by the resource compiler, and the resource compiler doesn't understand constants.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law