Re: #define and (brackets)

Tech-Archive recommends: Fix windows errors by optimizing your registry



Gerry Hickman wrote:
David Webber wrote:

I see I have started a long argument in this thread.

But it's interesting to learn about tokens, white space and macros and how they can lead to subtle bugs. I thought #define was easy until now!

They are easy. Use it wrong, like anything else, undefined behaviors
can happen.

#define FILE_READ_EA ( 0x0008 ) // file & directory
#define FILE_WRITE_EA ( 0x0010 ) // file & directory
#define FILE_EXECUTE ( 0x0020 ) // file
#define FILE_TRAVERSE ( 0x0020 ) // directory
#define FILE_DELETE_CHILD ( 0x0040 ) // directory

and I see they put some whitespace between the brackets and the number here.

Right. In this case, the white space is for clarity, the parentheses
or curved brackets are for token delimiters.

Some note:

() Parentheses or round or curved brackets
[] Brackets or squared brackets
<> Angle brackets
{} Curly Brackets or braces

---
.



Relevant Pages

  • Re: [[Shed]] token
    ... unfortunately I am posting from Google groups which seems to strip ... brackets from tokens, so this is by way of an experiment. ...
    (uk.rec.sheds)
  • [[Shed]] token
    ... unfortunately I am posting from Google groups which seems to strip ... brackets from tokens, so this is by way of an experiment. ...
    (uk.rec.sheds)
  • Re: tokens
    ... are 2 tokens, as each (has a a meaning to the compiler. ... pair of parentheses, a pair of brackets perhaps including a number. ... assume that their definition is for the sake of the example, ...
    (comp.lang.c)