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


Groups > comp.lang.c > #73640

Re: C function prototype and body definitions

From Melzzzzz <mel@zzzzz.com>
Newsgroups comp.lang.c
Subject Re: C function prototype and body definitions
Date 2015-10-23 19:44 +0200
Organization albasani.net
Message-ID <20151023194414.4c61e009@maxa-pc> (permalink)
References <ae13b44e-6dd4-4ff6-b62c-c0c8c58fbe50@googlegroups.com>

Show all headers | View raw


On Fri, 23 Oct 2015 10:37:07 -0700 (PDT)
"Rick C. Hodgin" <rick.c.hodgin@gmail.com> wrote:

> What is the reason for having both a function prototype and a body
> definition, when the body typically replicates the prototype?
> 
> ||||||||||
> || Why have these:
> || 
> ||     // myheader.h
> ||     int my_function(int, int, int);
> ||         // or this:
> ||         // int my_function(int a, int b, int c);
> || 
> ||     // myprogram.c
> ||     int my_function(int a, int b, int c)
> ||     {
> ||         // Code goes here
> ||     }
> ||||||
> 
> ||||||||||
> || Rather than something like this:
> || 
> ||     // myheader.h
> ||     int my_function(int a, int b, int c);
> || 
> ||     // myprogram.c
> ||     function my_function
> ||     {
> ||         // Code goes here
> ||     }
> ||||||
> 
> ?
> 

That would definitely put a nail in the coffin of C <-> C++
compatibility ;)

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


Thread

C function prototype and body definitions "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-23 10:37 -0700
  Re: C function prototype and body definitions Melzzzzz <mel@zzzzz.com> - 2015-10-23 19:44 +0200
  Re: C function prototype and body definitions Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-23 10:53 -0700
    Re: C function prototype and body definitions Keith Thompson <kst-u@mib.org> - 2015-10-23 12:19 -0700
      Re: C function prototype and body definitions "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-23 12:27 -0700
        Re: C function prototype and body definitions supercat@casperkitty.com - 2015-10-24 10:46 -0700
          Re: C function prototype and body definitions "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-10-24 12:17 -0700
    Re: C function prototype and body definitions Les Cargill <lcargill99@comcast.com> - 2015-10-23 20:56 -0500
      Re: C function prototype and body definitions gazelle@shell.xmission.com (Kenny McCormack) - 2015-10-24 09:49 +0000
  Re: C function prototype and body definitions Bartc <bc@freeuk.com> - 2015-10-23 19:16 +0100
  Re: C function prototype and body definitions Barry Schwarz <schwarzb@dqel.com> - 2015-10-23 11:30 -0700
  Re: C function prototype and body definitions sfisher@panix.com (Stephen Fisher) - 2015-10-23 15:58 -0600
  Re: C function prototype and body definitions Les Cargill <lcargill99@comcast.com> - 2015-10-23 20:54 -0500

csiph-web