From: Steve Graegert <graegerts@gmail.com>
To: _z33 <timid.Gentoo@gmail.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: default function parameters
Date: Fri, 9 Sep 2005 12:20:49 +0200 [thread overview]
Message-ID: <6a00c8d505090903206f2506f3@mail.gmail.com> (raw)
In-Reply-To: <dfrlh3$mqv$1@sea.gmane.org>
On 9/9/05, _z33 <timid.Gentoo@gmail.com> wrote:
> Steve Graegert wrote:
> > I have modified the code to clarify my thoughts:
> >
> > #include <stdio.h>
> >
> > /* prototype */
> > void add(); /* call with arbitrary number of arguments */
> >
> > void add (int a, int b, int c) {
> > printf ("inside function: add(%d, %d)\n", a, b);
> > return;
> > }
> >
> > int main (void) {
> > /* call function add with some parameters */
> > add(5, 1);
> > getc(stdin);
> >
> > return (0);
> > }
> >
> > Do you see the difference? No warning is issued, because there is
> > nothing wrong with it (it is not recommended by ANSI C99 but still
> > valid).
> >
>
> Inside "main", did you mean to write the function call as " add (5,
> 1, <some number>); ". Cos' when I copy the code, and try to run it, it
> throws me this error message during compilation.
> - too few arguments to function `add'-
No, the code given is exactly what I wanted to show. (The code you
provided was Windows code and I tested it under Windows without
complaints.)
Unfortunately, under Linux you cannot switch to "traditional" since it
would clash with libc which is an ISO C library. Under Solaris
(SPARCWorx) you may want to try -traditional and -fd. As far as I
know only SunOS and HP-UX (besides Windows) come with a native K&R C
compiler. All others do prototype checking.
> >> Am I fundamentally going wrong in my understanding of functions?
> >
> >
> > No you're not. You're just curious :-)
>
> Thanks!
>
next prev parent reply other threads:[~2005-09-09 10:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-09 18:43 default function parameters _z33
2005-09-09 6:47 ` Steve Graegert
2005-09-09 19:38 ` _z33
2005-09-09 7:36 ` Steve Graegert
2005-09-09 8:46 ` _z33
2005-09-09 9:23 ` Jarmo
2005-09-09 9:42 ` Steve Graegert
2005-09-09 9:58 ` _z33
2005-09-09 9:50 ` _z33
2005-09-09 9:34 ` Steve Graegert
2005-09-09 9:44 ` _z33
2005-09-09 10:20 ` Steve Graegert [this message]
2005-09-09 13:00 ` Glynn Clements
2005-09-09 12:50 ` Glynn Clements
2005-09-09 12:43 ` Glynn Clements
2005-09-10 5:00 ` _z33
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a00c8d505090903206f2506f3@mail.gmail.com \
--to=graegerts@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
--cc=timid.Gentoo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).