## symbol in C language

This is a discussion on ## symbol in C language within the C Programming forums, part of the General Programming Boards category; Dear all, I am reading existing source code, and meet ## symbol Really I don't know what does this symbol ...

  1. #1
    Registered User Hannibal2010's Avatar
    Join Date
    Jun 2011
    Location
    Hanoi, Vietnam
    Posts
    46

    ## symbol in C language

    Dear all,
    I am reading existing source code, and meet ## symbol

    Really I don't know what does this symbol mean?

    The line of code is:

    Code:
    char *cli_name ## _help[] = {##ARGS, NULL};
    Can you show me the meaning of ## ?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    19,365
    Read up on the C preprocessor, in particular on token concatenation.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User Hannibal2010's Avatar
    Join Date
    Jun 2011
    Location
    Hanoi, Vietnam
    Posts
    46
    Dear laserlight

    I only found this section:

    Code:
    ${variable##prefix}
    Substitute the value of variable, but first discard from that variable any portion at the beginning that matches the pattern prefix. 
    
    If there is more than one alternative for how to match against prefix, this construct uses the longest possible match. 
    
    Thus, ‘${foo##*t}’ substitutes ‘or’, because the largest match for ‘*t’ at the beginning of ‘tractor’ is ‘tract’.
    from: The GNU C Library

    But, actually, I don't understand its meaning

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    19,365
    You should be reading about the language feature of the preprocessor, not on the library.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User Hannibal2010's Avatar
    Join Date
    Jun 2011
    Location
    Hanoi, Vietnam
    Posts
    46
    Can you give me a link

  6. #6
    Registered User Hannibal2010's Avatar
    Join Date
    Jun 2011
    Location
    Hanoi, Vietnam
    Posts
    46
    Dear laserlight

    I found it, ## is used to concatenate two strings

    Preprocessor directives - C++ Documentation

    Thank you very much for your help

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    4,754
    Quote Originally Posted by Hannibal2010 View Post
    I found it, ## is used to concatenate two strings
    Actually, it concatenates two tokens.

    The term string has a particular meaning in C, and ## does not concatenate them.
    Right 98% of the time, and don't care about the other 3%.

  8. #8
    Registered User krime's Avatar
    Join Date
    Jul 2011
    Posts
    1

    Reply: ## symbol in C language

    Quote Originally Posted by Hannibal2010 View Post
    The line of code is:

    Code:
    char *cli_name ## _help[] = {##ARGS, NULL};
    I check ansi c 99 standard, the ## symbol only available in the replacement list for the macro definition, and it shall not occur at the beginning or at the end of a replacement list. Can you paste the whole document nor even share your reading project to me?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ~ symbol
    By vurentjie in forum C Programming
    Replies: 2
    Last Post: 06-02-2008, 03:20 AM
  2. What's the Difference Between a Programming Language and a Scripting Language?
    By Krak in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 07-15-2005, 04:46 PM
  3. C Language And A Scripting Language
    By DarkSpy in forum C Programming
    Replies: 9
    Last Post: 06-26-2003, 08:05 AM
  4. Computer Language VS Spoken Language
    By Isometric in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 02-04-2002, 02:47 PM
  5. What does this symbol mean: ->
    By deregistered in forum C Programming
    Replies: 10
    Last Post: 01-02-2002, 12:45 PM

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