linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarmo <SVisor@lycos.com>
To: linux-c-programming@vger.kernel.org
Subject: Re: default function parameters
Date: Fri, 09 Sep 2005 11:23:58 +0200	[thread overview]
Message-ID: <dfrkb4$j56$1@sea.gmane.org> (raw)
In-Reply-To: <dfri55$cse$1@sea.gmane.org>

There is a diff in how C and C++ sees this.

For C add( ) is an function taking undefined argument(s), so you can 
send it whatever you want. C++ on other hand will see add( ) as add( 
void ), and would complain. To say that add( ) would be equal to add( 
int(s) ) is bogus thou.

In real life this does not matter. This is a completely academic 
question. Thou *I think* even the C compiler should have given a 
warning. (Note -Wall does not turn on all warnings, just almost all).

// Jarmo

-- 

>> Unless you're writing a compiler this does not matter.  Even if an int
>> argument in implicitly used it has no meaning to the programmer. Since 
>> void is a well defined type, although an incomplete one, I have
>> doubts that int is used internally.  I simply can't see the rationale
>> behind that (but I'd be happy to be enlightened).  Could you please
>> try to transport your collegue's argumentation?
> 
> Here is what he sent me -
> 
>     #include <stdio.h>
>     
>     void add ()
>     {   
>          printf ("inside function: add. \n");
>         
>          return;
>     }
> 
>     int main (void)
>     {
>         /* call function add with some parameters */
>         add (5, 1);
>        
>         system ("PAUSE");
>     
>         return (0);
>     }
> 
>   How can this work, if not specifying any argument, is equivalent to 
> specifying as void?
>   However, one thing I was able observe was that it accepts any kind of 
> arguments, and also any number of arguments, as against his theory of 
> only accepting "int" types.
>   I even tried compiling with "-Wall" option to see if any warnings are 
> being thrown by the compiler, but found to my disappointment that there 
> was none.
>   Am I fundamentally going wrong in my understanding of functions?
> 
> _z33


  reply	other threads:[~2005-09-09  9:23 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 [this message]
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
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='dfrkb4$j56$1@sea.gmane.org' \
    --to=svisor@lycos.com \
    --cc=linux-c-programming@vger.kernel.org \
    /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).