Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Message-ID | <503FADD2.80702@verizon.net> (permalink) |
|---|---|
| Newsgroups | comp.std.c++ |
| From | James Kuyper <jameskuyper@verizon.net> |
| Subject | Re: Unused named function argument |
| Organization | A noiseless patient Spider |
| References | <61b7661d-5cbf-4246-93a2-4ab9dcc6ed12@googlegroups.com> |
| Date | 2012-08-31 09:20 -0600 |
On 08/30/2012 12:36 PM, andrew.gottemoller@debesys.net wrote:
>
> When compiling using gcc with, the below code will compile without any sort of error:
>
>
> int foo (int)
> {
> return 5;
> }
>
>
> Can the compilation result differ if I specify a name for the argument?
>
> I can't see any way the naming of the parameter would ever make a difference in the actual compilation result. The question arose because I noticed when compiling the following C program:
>
>
> // Compile: gcc --std=c99 -c -pedantic -Wall -O3 foo.c
> int foo (int)
> {
> return 5;
> }
>
>
> The error: 'parameter name omitted' is output by the compiler.
>
> Is there any non-obvious significance in the parameter name with C++11 or C99?
In n1570 (which is very close to C2011) 6.9.1p5 is a constraint applying
to function definitions: "If the declarator includes a parameter type
list, the declaration of each parameter shall include an identifier,
except for the special case of a parameter list consisting of a single
parameter of type void, in which case there shall not be an identifier.
..." The C99 wording was identical.
6.9.1p6 says equivalent things about K&R style function declarations,
which are still allowed.
I could find no comparable wording in the C++ standard, so this may not
be true of C++11.
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to comp.std.c++ | Previous | Next — Previous in thread | Next in thread | Find similar
Unused named function argument andrew.gottemoller@debesys.net - 2012-08-30 10:36 -0600
Re: Unused named function argument James Kuyper <jameskuyper@verizon.net> - 2012-08-31 09:20 -0600
Re: Unused named function argument Daniel Krügler<daniel.kruegler@googlemail.com> - 2012-09-05 11:24 -0700
Re: Unused named function argument James Kuyper <jameskuyper@verizon.net> - 2012-09-06 13:04 -0600
csiph-web