Thread: Never encounter such coding

  1. #1
    Registered User
    Join Date
    Aug 2005

    Never encounter such coding

    Hi all,

    i have never encounter a code that is written this way. From my experience, isn't a code is suppose to end when ; is encounter? So why is the following code has a \ after ; . can someone explain to me what the following code means?

    #define a   (b |= ~c); \          //What is \ after ;
                (d |= e); \
                (f &= ~g); \
                (h |= i);

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    It's just a line continuation.
    #defines can only exist on one line, so it's just a nice way of saying

    #define a (b |= ~c); (d |= e); (f &= ~g); (h |= i);

  3. #3
    Registered User
    Join Date
    Dec 2005
    Australia - Melbourne
    your code tells a preprocessor (a specialised text editor) to replace a in your source code with:
    (b |= ~c);    
    (d |= e); 
    (f &= ~g);
    (h |= i);
    before it is actually compiled.

    a #define ... terminates at the end of line. putting \ there continues that line (to the one below).

    that bit of code (#define a ...) is not actually c, which you are lead to believe. i've read that the syntax of the preprocessor is completely different to c.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    The preprocessor is part of the C language. So it is actually C. It's behaviour is defined by the C standard.

    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Aug 2005
    I see, i see....well that should clear all the clouds...Thanks guys (or gals)...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 03-20-2009, 05:22 PM
  2. Coding Guideline ....!!
    By imfeelingfortun in forum Tech Board
    Replies: 8
    Last Post: 10-08-2006, 07:09 AM
  3. Before Coding
    By cyberCLoWn in forum C++ Programming
    Replies: 16
    Last Post: 12-15-2003, 01:26 AM
  4. Coding Contest....
    By Koshare in forum A Brief History of
    Replies: 46
    Last Post: 10-14-2001, 04:32 PM
Website Security Test