Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #22232

Re: Empty function parameter list

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: Empty function parameter list
Date 2012-06-13 18:50 -0400
Organization A noiseless patient Spider
Message-ID <4FD91925.8070407@verizon.net> (permalink)
References <e3aacc3b-f17b-4da8-a1e6-f54b3273ecf0@x21g2000vbc.googlegroups.com> <jrb4lg$j06$1@dont-email.me>

Show all headers | View raw


On 06/13/2012 06:36 PM, Eric Sosman wrote:
> On 6/13/2012 5:48 PM, Maxim Fomin wrote:
...
>> #include <stdio.h>
>>
>> int (*funcptr)();
>>
>> int foo(int x)
>> {
>> 	return x;
>> }
>>
>> int main()
>> {
>> 	funcptr = foo;
> 
>      I expected a diagnostic here because the parameter lists `()'
> and `(int x)' are different, making the types of `funcptr' and
> `foo' different.  But "different" and "incompatible" are not quite
> the same, and I'm not 100% sure about whether this assignment is
> legal or not.  Let's leave it to the language lawyers, okay?

I answered the rest of his message, but missed his original question.

A function type with an unspecified number of arguments is compatible
with one that has a parameter type list, which is why that is not a
constraint violation. The requirement in 6.7.6.3p15, that both function
types must have matching parameter lists, only applies "if both are
present". If either parameter list is not present, then the parameter
list that is present doesn't interfere with compatibility.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Empty function parameter list Maxim Fomin <maxim@maxim-fomin.ru> - 2012-06-13 14:48 -0700
  Re: Empty function parameter list Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-13 18:36 -0400
    Re: Empty function parameter list James Kuyper <jameskuyper@verizon.net> - 2012-06-13 18:50 -0400
      Re: Empty function parameter list Maxim Fomin <maxim@maxim-fomin.ru> - 2012-06-15 02:08 -0700
        Re: Empty function parameter list Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-15 11:30 +0100
  Re: Empty function parameter list James Kuyper <jameskuyper@verizon.net> - 2012-06-13 18:38 -0400
  Re: Empty function parameter list Dinesh Kalal <mr.dineshkalal@gmail.com> - 2012-06-15 01:35 -0700
    Re: Empty function parameter list James Kuyper <jameskuyper@verizon.net> - 2012-06-15 08:22 -0400

csiph-web