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


Groups > comp.std.c > #1228

Is this a prototype or not

From jacob navia <jacob@spamsink.net>
Newsgroups comp.std.c
Subject Is this a prototype or not
Date 2012-04-09 22:16 +0200
Organization lccwin
Message-ID <4F8343A5.6060402@spamsink.net> (permalink)

Show all headers | View raw


Consider the following code:

int fn()
{
	return fn(56);
}

According to the C99 standard

ยง6.7.5.3 "Function declarators (including prototypes)"
says in constraint 14:

14 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.126)

My reading is that the construct

int fn()

should be considered a prototype because

An empty list in a function declarator that is part of a definition of 
that function specifies that the function has no parameters

Neither gcc, (with -pedantic -Wall) nor my compiler nor MSVC complain 
about the obvious error.

I think that I have a very common bug. What is actually the correct 
interpretation?

Thanks in advance.

Jacob navia

Back to comp.std.c | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Is this a prototype or not jacob navia <jacob@spamsink.net> - 2012-04-09 22:16 +0200
  Re: Is this a prototype or not Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-04-09 23:13 +0100
    Re: Is this a prototype or not Tim Rentsch <txr@alumni.caltech.edu> - 2012-04-09 18:16 -0700
      Re: Is this a prototype or not Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-04-10 02:30 +0100
  Re: Is this a prototype or not Tim Rentsch <txr@alumni.caltech.edu> - 2012-04-09 18:07 -0700
    Re: Is this a prototype or not jacob navia <jacob@spamsink.net> - 2012-04-10 21:11 +0200
      Re: Is this a prototype or not Philip Lantz <prl@canterey.us> - 2012-04-13 00:36 -0700
  Re: Is this a prototype or not Harald van Dijk <haraldvdijk@gmail.com> - 2012-04-10 13:57 -0700
    Re: Is this a prototype or not Nick Bowler <nbowler@draconx.ca> - 2012-08-15 15:56 +0000
      Re: Is this a prototype or not Jens Gustedt <jens.gustedt@loria.fr> - 2012-08-15 19:07 +0200
        Re: Is this a prototype or not Nick Bowler <nbowler@draconx.ca> - 2012-08-23 19:59 +0000
  Re: Is this a prototype or not Philip Lantz <prl@canterey.us> - 2012-04-13 00:25 -0700
  Re: Is this a prototype or not Vlad from Moscow <vlad.moscow@mail.ru> - 2012-08-17 02:49 -0700
    Re: Is this a prototype or not Vlad from Moscow <vlad.moscow@mail.ru> - 2012-08-17 03:14 -0700
    Re: Is this a prototype or not Keith Thompson <kst-u@mib.org> - 2012-08-17 13:05 -0700
      Re: Is this a prototype or not Vlad from Moscow <vlad.moscow@mail.ru> - 2012-08-18 05:27 -0700

csiph-web