F
Francis Moreau
Hello,
I read section 6.7.5.3p14 from C99 several times but it looks I missed
something in my understanding...
I put the revelant section for convenience:
An identifier list declares only the identifiers of the parameters
of the function. An empty
list in a function declarator that is part of a definition of that
function specifies that the
function has no parameters. The empty list in a function declarator
that is not part of a
definition of that function specifies that no information about the
number or types of the
parameters is supplied.
So to check that I understood correctly this, I wrote and tried to
compile the following code:
--- 8< ---
/*
* A function declaration with empty identifier list which is part of
* the definition specifies that the function has no parameters.
*/
int foo()
{
return 1;
}
/* A function declaration alone with empty list identifier specifies
* that no information about the number or types of the parameters is
* supplied.
*/
int bar();
void test(void)
{
foo(1); /* should fail */
bar(1); /* should be ok */
}
--- >8 ---
Gcc compiles this without any warnings (gcc -Wall -std=c99 -c func.c).
However I would expect gcc to issue an error or a warning since 'foo'
function takes no parameters (in my understanding).
Could anybody enlight me ?
Thanks
I read section 6.7.5.3p14 from C99 several times but it looks I missed
something in my understanding...
I put the revelant section for convenience:
An identifier list declares only the identifiers of the parameters
of the function. An empty
list in a function declarator that is part of a definition of that
function specifies that the
function has no parameters. The empty list in a function declarator
that is not part of a
definition of that function specifies that no information about the
number or types of the
parameters is supplied.
So to check that I understood correctly this, I wrote and tried to
compile the following code:
--- 8< ---
/*
* A function declaration with empty identifier list which is part of
* the definition specifies that the function has no parameters.
*/
int foo()
{
return 1;
}
/* A function declaration alone with empty list identifier specifies
* that no information about the number or types of the parameters is
* supplied.
*/
int bar();
void test(void)
{
foo(1); /* should fail */
bar(1); /* should be ok */
}
--- >8 ---
Gcc compiles this without any warnings (gcc -Wall -std=c99 -c func.c).
However I would expect gcc to issue an error or a warning since 'foo'
function takes no parameters (in my understanding).
Could anybody enlight me ?
Thanks