signify?? -- "\" One line Code

This is a discussion on signify?? -- "\" One line Code within the C Programming forums, part of the General Programming Boards category; Code: /* =========================================================================== * Initialize the hash table (avoiding 64K overflow for 16 bit systems). * prev[] will be initialized ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    10

    signify?? -- "\" One line Code

    Code:
    /* ===========================================================================
     * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
     * prev[] will be initialized on the fly.
     */
    #define CLEAR_HASH(s) \
        s->head[s->hash_size-1] = NIL; \
        zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
    
    /* ========================================================================= */
    What is significance of "\" ?
    And if possible could you explain the code ?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It means "continue this line on the next line", which prevents the line from being "infinitely long".

    I personally do not like multiline macros like that. It is much better to write a small function - modern compilers will be able to inline the function if it's defined in a header file, and it will be possible to debug the line, rather than having a "step over all of it" nightmare.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,012
    Quote Originally Posted by matsp View Post
    I personally do not like multiline macros like that. It is much better to write a small function - modern compilers will be able to inline the function if it's defined in a header file, and it will be possible to debug the line, rather than having a "step over all of it" nightmare.
    I would agree, but sometimes it's the only effective solution in C. It isn't know for its generics, after all.
    It would be faster than typing out a number of different functions to work with different types.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    Then again, macros aren't type strict either. Isn't the opportunity cost for something like that too great? You'd have to do generic programming an entirely different way or even use another language.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing Length of Input and the Limited Input
    By dnguyen1022 in forum C Programming
    Replies: 33
    Last Post: 11-29-2008, 04:13 PM
  2. ASM beginner gets 24 compiler errors on hello world...
    By Desolation in forum Tech Board
    Replies: 12
    Last Post: 06-16-2007, 11:21 PM
  3. What does this line of code mean?
    By diagonalArg in forum C++ Programming
    Replies: 3
    Last Post: 07-28-2005, 01:59 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  5. Greenhand want help!
    By leereg in forum C Programming
    Replies: 6
    Last Post: 01-29-2002, 06:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21