Underscore

Discussion in 'C Programming' started by foaud167, Jan 5, 2005.

  1. foaud167

    foaud167 Guest

    i was looking at the code of GNU m4 (/src/eval.c to be specific) and
    saw this in function prototypes

    static eval_error logical_or_term _((eval_token, eval_t *));
    __________________________________^

    what is this underscore for?
     
    foaud167, Jan 5, 2005
    #1
    1. Advertising

  2. foaud167

    Villy Kruse Guest

    On 5 Jan 2005 05:29:09 -0800,
    foaud167 <> wrote:


    > i was looking at the code of GNU m4 (/src/eval.c to be specific) and
    > saw this in function prototypes
    >
    > static eval_error logical_or_term _((eval_token, eval_t *));
    > __________________________________^
    >
    > what is this underscore for?
    >


    It is a macro, defined in one of the #include files. Probably
    the purpose is to create a pre-ANSI or proper ANSI prototype depending on
    the compiler being used.


    Villy
     
    Villy Kruse, Jan 5, 2005
    #2
    1. Advertising

  3. On 5 Jan 2005 05:29:09 -0800, foaud167
    <> wrote:

    > i was looking at the code of GNU m4 (/src/eval.c to be specific) and
    > saw this in function prototypes
    >
    > static eval_error logical_or_term _((eval_token, eval_t *));
    > __________________________________^
    >
    > what is this underscore for?


    Underscore is a valid character for an identifier. Admitedly it's not
    usual to just have _ as a name, but that's presumably why it's used.

    In this case, you should find it in a #define in a header file
    somewhere, defining a macro. This is used to switch function prototype
    arguments off for pre-ISO compilers, something like:

    #ifdef NO_PROTOTYPES
    #define _(x) ()
    #else
    #define _(x) x
    #endif

    Thus if NO_PROTOTYPES is defined, the prototype you quote will be

    static eval_error logical_or_term ();

    otherwise (normally now) it will be

    static eval_error logical_or_term (eval_token, eval_t *);

    Chris C
     
    Chris Croughton, Jan 5, 2005
    #3
    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. Antonio
    Replies:
    2
    Views:
    429
    tdavisjr
    Nov 4, 2005
  2. Kerry Kimbrough
    Replies:
    6
    Views:
    14,900
    Chris Smith
    Feb 27, 2004
  3. ABC
    Replies:
    1
    Views:
    2,016
    Kevin Spencer
    Apr 22, 2006
  4. Mikael Petterson

    Problem to remove underscore in template

    Mikael Petterson, Sep 20, 2003, in forum: XML
    Replies:
    4
    Views:
    578
    Mikael Petterson
    Sep 20, 2003
  5. Kanon
    Replies:
    1
    Views:
    454
    Florent Georges
    Dec 26, 2005
Loading...

Share This Page