Thread: Never encounter such coding

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    21

    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?


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

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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
    Location
    Australia - Melbourne
    Posts
    63
    your code tells a preprocessor (a specialised text editor) to replace a in your source code with:
    Code:
    (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
    Posts
    14,826
    The preprocessor is part of the C language. So it is actually C. It's behaviour is defined by the C standard.


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Aug 2005
    Posts
    21
    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, 02:26 AM
  4. Coding Contest....
    By Koshare in forum A Brief History of Cprogramming.com
    Replies: 46
    Last Post: 10-14-2001, 04:32 PM