Function Parameter-List with Identifiers

Discussion in 'C Programming' started by Shao Miller, Apr 25, 2012.

  1. Shao Miller

    Shao Miller Guest

    Good day, respected regulars and other readers!

    Quick question: At file scope, suppose we have:

    extern void foo(int Bar);
    void foo(int bar) { return; }

    (Please note the case.) I seem to recall some bit about the former
    parameter identifiers being ignored, but can't seem to find that bit.
    Does anyone recall if that's so? It's not an identifier-list, but a
    parameter-list.

    Thank you for your time.

    - Shao Miller
    Shao Miller, Apr 25, 2012
    #1
    1. Advertising

  2. Shao Miller

    Stefan Ram Guest

    Shao Miller <> writes:
    >parameter identifiers being ignored


    N1570 6.7.6.3p15
    Stefan Ram, Apr 25, 2012
    #2
    1. Advertising

  3. Shao Miller

    Ben Pfaff Guest

    Shao Miller <> writes:

    > Quick question: At file scope, suppose we have:
    >
    > extern void foo(int Bar);
    > void foo(int bar) { return; }
    >
    > (Please note the case.) I seem to recall some bit about the former
    > parameter identifiers being ignored, but can't seem to find that
    > bit. Does anyone recall if that's so? It's not an identifier-list,
    > but a parameter-list.


    It is so. You can even add "const" to one of the prototypes, if
    you like.

    (If you want, I'll look up a reference for you.)
    Ben Pfaff, Apr 25, 2012
    #3
  4. Shao Miller

    Shao Miller Guest

    On 4/25/2012 16:45, Stefan Ram wrote:
    > Shao Miller<> writes:
    >> parameter identifiers being ignored

    >
    > N1570 6.7.6.3p15
    >


    Thank you for your response.

    Forgive me, but I don't quite follow the relevance of that paragraph.
    It's discussing compatible types. Are you suggesting this piece because
    of 6.7p4?
    Shao Miller, Apr 25, 2012
    #4
  5. Shao Miller

    Shao Miller Guest

    On 4/25/2012 16:50, Ben Pfaff wrote:
    > Shao Miller<> writes:
    >
    >> Quick question: At file scope, suppose we have:
    >>
    >> extern void foo(int Bar);
    >> void foo(int bar) { return; }
    >>
    >> (Please note the case.) I seem to recall some bit about the former
    >> parameter identifiers being ignored, but can't seem to find that
    >> bit. Does anyone recall if that's so? It's not an identifier-list,
    >> but a parameter-list.

    >
    > It is so. You can even add "const" to one of the prototypes, if
    > you like.
    >
    > (If you want, I'll look up a reference for you.)


    Thank you for your response.

    Since 'const' is a type qualifier, I'm sure you weren't referring to
    N1570 6.7.6.3p13 (where 6.7.6.3p2 is relevant for that, too).

    Were you suggesting this because of N1570 6.7p4 and 6.7.6.3p15; that
    type compatibility is the only consideration for this particular example?
    Shao Miller, Apr 25, 2012
    #5
  6. Shao Miller

    Stefan Ram Guest

    Shao Miller <> writes:
    >>N1570 6.7.6.3p15

    >It's discussing compatible types. Are you suggesting this piece because
    >of 6.7p4?


    I mention it because it does not mention the parameter identifiers, and
    because of 6.2.7p2.
    Stefan Ram, Apr 25, 2012
    #6
  7. Shao Miller

    Ben Pfaff Guest

    Shao Miller <> writes:

    > On 4/25/2012 16:50, Ben Pfaff wrote:
    >> Shao Miller<> writes:
    >>
    >>> Quick question: At file scope, suppose we have:
    >>>
    >>> extern void foo(int Bar);
    >>> void foo(int bar) { return; }
    >>>
    >>> (Please note the case.) I seem to recall some bit about the former
    >>> parameter identifiers being ignored, but can't seem to find that
    >>> bit. Does anyone recall if that's so? It's not an identifier-list,
    >>> but a parameter-list.

    >>
    >> It is so. You can even add "const" to one of the prototypes, if
    >> you like.
    >>
    >> (If you want, I'll look up a reference for you.)

    >
    > Thank you for your response.
    >
    > Since 'const' is a type qualifier, I'm sure you weren't referring to
    > N1570 6.7.6.3p13 (where 6.7.6.3p2 is relevant for that, too).


    I don't have N1570 conveniently at hand.

    I'm talking about the final sentence in paragraph 13 in C99
    6.7.5.3 "Function declarators (including prototypes)":

    (In the determination of type compatibility and of a
    composite type, each parameter declared with function or
    array type is taken as having the adjusted type and each
    parameter declared with qualified type is taken as having
    the unqualified version of its declared type.)

    > Were you suggesting this because of N1570 6.7p4 and 6.7.6.3p15; that
    > type compatibility is the only consideration for this particular
    > example?


    Sorry, the lack of N1570 makes me not follow this.
    Ben Pfaff, Apr 25, 2012
    #7
  8. Shao Miller

    Shao Miller Guest

    On 4/25/2012 18:08, Stefan Ram wrote:
    > Shao Miller<> writes:
    >>> N1570 6.7.6.3p15

    >> It's discussing compatible types. Are you suggesting this piece because
    >> of 6.7p4?

    >
    > I mention it because it does not mention the parameter identifiers, and
    > because of 6.2.7p2.
    >


    Ok, thanks! :)
    Shao Miller, Apr 25, 2012
    #8
  9. Shao Miller

    Shao Miller Guest

    On 4/25/2012 18:20, pete wrote:
    > Shao Miller wrote:
    >>
    >> Good day, respected regulars and other readers!
    >>
    >> Quick question: At file scope, suppose we have:
    >>
    >> extern void foo(int Bar);
    >> void foo(int bar) { return; }
    >>
    >> (Please note the case.) I seem to recall some bit about the former
    >> parameter identifiers being ignored, but can't seem to find that bit.
    >> Does anyone recall if that's so? It's not an identifier-list, but a
    >> parameter-list.
    >>
    >> Thank you for your time.

    >
    > n1570
    >
    > 6.2 Concepts
    > 6.2.1 Scopes of identifiers
    >
    > 4 If the declarator or type specifier
    > that declares the identifier appears
    > within the list of parameter declarations in a function prototype
    > (not part of a function definition),
    > the identifier has function prototype scope,
    > which terminates at the end of the function declarator.
    >


    I'm pretty sure that this is the one I was having "reader's block" or
    "finder's block" with. Thanks a lot, pete!
    Shao Miller, Apr 25, 2012
    #9
  10. Shao Miller

    Shao Miller Guest

    On 4/25/2012 18:22, Ben Pfaff wrote:
    > Shao Miller<> writes:
    >
    >> On 4/25/2012 16:50, Ben Pfaff wrote:
    >>> Shao Miller<> writes:
    >>>
    >>>> Quick question: At file scope, suppose we have:
    >>>>
    >>>> extern void foo(int Bar);
    >>>> void foo(int bar) { return; }
    >>>>
    >>>> (Please note the case.) I seem to recall some bit about the former
    >>>> parameter identifiers being ignored, but can't seem to find that
    >>>> bit. Does anyone recall if that's so? It's not an identifier-list,
    >>>> but a parameter-list.
    >>>
    >>> It is so. You can even add "const" to one of the prototypes, if
    >>> you like.
    >>>
    >>> (If you want, I'll look up a reference for you.)

    >>
    >> Thank you for your response.
    >>
    >> Since 'const' is a type qualifier, I'm sure you weren't referring to
    >> N1570 6.7.6.3p13 (where 6.7.6.3p2 is relevant for that, too).

    >
    > I don't have N1570 conveniently at hand.
    >
    > I'm talking about the final sentence in paragraph 13 in C99
    > 6.7.5.3 "Function declarators (including prototypes)":
    >
    > (In the determination of type compatibility and of a
    > composite type, each parameter declared with function or
    > array type is taken as having the adjusted type and each
    > parameter declared with qualified type is taken as having
    > the unqualified version of its declared type.)
    >
    >> Were you suggesting this because of N1570 6.7p4 and 6.7.6.3p15; that
    >> type compatibility is the only consideration for this particular
    >> example?

    >
    > Sorry, the lack of N1570 makes me not follow this.


    Right, that's the C99 counterpart. Thanks!
    Shao Miller, Apr 25, 2012
    #10
    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. Replies:
    4
    Views:
    518
    Matteo
    Mar 29, 2007
  2. Replies:
    1
    Views:
    351
    Roedy Green
    Apr 22, 2008
  3. Jeremy Banks
    Replies:
    12
    Views:
    435
    Steven D'Aprano
    Apr 24, 2009
  4. Mister B
    Replies:
    8
    Views:
    549
    Nick Keighley
    Aug 26, 2010
  5. AzamSharp
    Replies:
    2
    Views:
    174
Loading...

Share This Page