Re: Void function returns value
- From: "Antoine Leca" <root@xxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Oct 2007 19:15:48 +0100
En news:fgaann$ut9$1@xxxxxxxx, Philip Potter va escriure:
Antoine Leca wrote:
void foo() {;}The type of foo is [...] void(*)(void),
int main() {
void *k;
k = foo;
I believe there are no prototype in scope, so I think the type of
foo is rather void(*)().
Is that a distinct type?
My reading of 6.7.5.3p15 is that they are different, but compatible.
In both cases foo is declared as taking no arguments.
I read http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_317.htm as saying
that
void foo() {}
is also compatible with
void g(){ if(0) foo(1); }
While I know that
void foo(void);
void g(){ if(0) foo(1); }
should be diagnosed.
But I can easily be wrong on this one, so please check the holy words from
the knowledgeable people (there was a recent thread about this, subject was
"Prototype or not prototype?")
Antoine
.
- References:
- Re: Void function returns value
- From: Richard Heathfield
- Re: Void function returns value
- From: Antoine Leca
- Re: Void function returns value
- From: Philip Potter
- Re: Void function returns value
- Prev by Date: Re: Void function returns value
- Next by Date: Re: Void function returns value
- Previous by thread: Re: Void function returns value
- Next by thread: Re: Void function returns value
- Index(es):
Relevant Pages
|