Help with a #define?

Discussion in 'C++' started by Martin De Kauwe, Feb 14, 2011.

  1. Hi,

    I am trying to translate some c++ code and have run into an expression
    which makes no sense to me? I have a C background so understand the
    #define, but not what the use of the double ## means, e.g. x##n?

    Any assistance would be much appreciated...

    #define NCLIMIT(x,mn,mx) x##n += nclimit (x, x##n, mn, mx)
     
    Martin De Kauwe, Feb 14, 2011
    #1
    1. Advertising

  2. Martin De Kauwe

    Ian Collins Guest

    On 02/15/11 12:36 PM, Martin De Kauwe wrote:
    > Hi,
    >
    > I am trying to translate some c++ code and have run into an expression
    > which makes no sense to me? I have a C background so understand the
    > #define, but not what the use of the double ## means, e.g. x##n?
    >
    > Any assistance would be much appreciated...


    It's bizarre how often this gets asked, look up concatenation (or even
    ##) in your trusty copy of K&R. It's also the first item in the index
    of The C++ programming language!

    --
    Ian Collins
     
    Ian Collins, Feb 14, 2011
    #2
    1. Advertising

  3. On Feb 15, 10:44 am, Ian Collins <> wrote:
    > On 02/15/11 12:36 PM, Martin De Kauwe wrote:
    >
    > > Hi,

    >
    > > I am trying to translate some c++ code and have run into an expression
    > > which makes no sense to me? I have a C background so understand the
    > > #define, but not what the use of the double ## means, e.g. x##n?

    >
    > > Any assistance would be much appreciated...

    >
    > It's bizarre how often this gets asked, look up concatenation (or even
    > ##) in your trusty copy of K&R.  It's also the first item in the index
    > of The C++ programming language!
    >
    > --
    > Ian Collins


    Hi,

    thanks as you say it is right there in K&R! I guess instead of looking
    in the book I tried googling and well not an easy keyword to find it
    seems!
     
    Martin De Kauwe, Feb 15, 2011
    #3
  4. Martin De Kauwe

    Ian Collins Guest

    On 02/15/11 07:02 PM, Martin De Kauwe wrote:
    > On Feb 15, 10:44 am, Ian Collins<> wrote:
    >> On 02/15/11 12:36 PM, Martin De Kauwe wrote:
    >>
    >>> Hi,

    >>
    >>> I am trying to translate some c++ code and have run into an expression
    >>> which makes no sense to me? I have a C background so understand the
    >>> #define, but not what the use of the double ## means, e.g. x##n?

    >>
    >>> Any assistance would be much appreciated...

    >>
    >> It's bizarre how often this gets asked, look up concatenation (or even
    >> ##) in your trusty copy of K&R. It's also the first item in the index
    >> of The C++ programming language!


    > Hi,
    >
    > thanks as you say it is right there in K&R! I guess instead of looking
    > in the book I tried googling and well not an easy keyword to find it
    > seems!


    You still can't beat the printed word!

    --
    Ian Collins
     
    Ian Collins, Feb 15, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Student911
    Replies:
    5
    Views:
    438
    Karl Heinz Buchegger
    Jan 26, 2005
  2. theotyflos
    Replies:
    3
    Views:
    482
    Thomas Matthews
    Feb 19, 2004
  3. pozz

    Help with #define

    pozz, Apr 22, 2004, in forum: C Programming
    Replies:
    9
    Views:
    413
    Sam Dennis
    Apr 28, 2004
  4. robin liu
    Replies:
    3
    Views:
    832
    Robin Liu
    Apr 21, 2006
  5. Brian Takita

    #define _ and #define __

    Brian Takita, Jan 23, 2006, in forum: Ruby
    Replies:
    0
    Views:
    481
    Brian Takita
    Jan 23, 2006
Loading...

Share This Page