Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > C Macro questions

Reply
Thread Tools

C Macro questions

 
 
J. J. Farrell
Guest
Posts: n/a
 
      01-18-2008
Billy Bong wrote:
> On Tue, 15 Jan 2008 20:28:11 -0800, user923005 wrote:
>
>> On Jan 15, 8:02 pm, "(E-Mail Removed)" <(E-Mail Removed)>
>> wrote:
>>> 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.

>> From the current C standard:
>> 6.4.4.4 Character constants
>> Syntax
>> 1 character-constant:
>> ' c-char-sequence '
>> L' c-char-sequence '
>> c-char-sequence:
>> c-char
>> c-char-sequence c-char
>> c-char:
>> any member of the source character set except
>> the single-quote ', backslash \, or new-line character
>> escape-sequence
>> escape-sequence:
>> simple-escape-sequence
>> octal-escape-sequence
>> hexadecimal-escape-sequence
>> universal-character-name
>> simple-escape-sequence: one of
>> \' \" \? \\
>> \a \b \f \n \r \t \v
>> octal-escape-sequence:
>> \ octal-digit
>> \ octal-digit octal-digit
>> \ octal-digit octal-digit octal-digit
>> hexadecimal-escape-sequence:
>> \x hexadecimal-digit
>> hexadecimal-escape-sequence hexadecimal-digit

>
> 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
> something like this:
>
> void main(void)
> {
> }


Why do you think he was mad? Why do you think he may well write invalid
code?

> An explanation for "the logic behind this usage" is NOT that it is
> undefined behavior (which is true, i.e., not 0)


What is undefined about it? Looks fine to me.

> , 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).


What's illogical about it, and what mistakes has he not learned from?

> Recently, I've become real good at firing--oops, I mean laying off--
> madmen.


I doubt it; you appear to have a very strange idea of "madmen".
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dedicated Macro or Normal Macro? John Ortt Digital Photography 5 11-22-2005 12:43 PM
Macro lens on a camera with a macro setting??? mitchell.chris@gmail.com Digital Photography 2 09-28-2005 07:55 AM
in S.E. Asia : Canon EOS 300d with 100 macro ED vs. Nikon D70 with Nikon 105 macro ? J. Cod Digital Photography 0 09-29-2004 05:46 AM
#define macro to enclose an older macro with strings Dead RAM C++ 20 07-14-2004 10:58 AM
macro name from macro? D Senthil Kumar C Programming 1 09-21-2003 07:02 PM



Advertisments