Hi Friends,
I saw a usage of macro like
#define B3 "\xA\xB\xC"
I don't understand why B3[0] is digital 10, can ayone point what the
logic behind this usage.
[snip]
That explains the macro, but it does not explain "the logic behind this
usage", as the OP put it.
In other words, the same madman who wrote that macro may well do
Do you think you impress by using terms like "madman"? Especially by
using them in describing a macro that might have a perfectly valid
use, perhaps not immediately apparent when seen out of context?
something like this:
void main(void)
{
}
An explanation for "the logic behind this usage" is NOT that it is
undefined behavior (which is true, i.e., not 0) , but rather that the
person who wrote this is a madman (i.e., his decision to use such code
defies logic, and he has not, or is not willing to, learn from his
mistakes).
There are so many things wrong with your statements that I hardly know
where to start.
What possible mental quirk causes you to make the leap between the
definition of a perfectly valid macro and the use of an incorrect
return type for main?
What possible reasoning do you have for proclaiming the author of the
macro a "madman", that his code "defies logic", and is a "mistake" he
has not learned from?
What is there about the macro definition that makes it a mistake?
Recently, I've become real good at firing--oops, I mean laying off--
madmen.
I've written similar macros many times for many reasons, not the least
of which is in defining terminal control strings for an ANSI terminal:
#define ANSI_START "\x1b["
#define ANSI_CLEAR ANSI_START "2J"
You have no idea whatsoever why the original programmer wrote the
macro, or even how close to the real macro the OP is asking about to
what he posted, since he said "something like this".
You have no idea at all if the programmer was defining byte sequences
required by some hardware device or some communications protocol.
And, since no code "something like" the code that actually used the
macro was presented, you have no idea at all if the use of the macro
clarified the code and made it much more readable, or not.
Gratuitous insults without justification are merely liable to get you
ignored at best, plonked at worst.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://c-faq.com/
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html