On 9/9/05, Jarmo <[EMAIL PROTECTED]> wrote:
> 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.

Exactly.  A point I have missed to mention.  Thanks.

> Thou *I think* even the C compiler should have given a
> warning. (Note -Wall does not turn on all warnings, just almost all).

try -ansi combined with -pedantic.

> >> 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
>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" 
in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to