• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Re: Passing too many parameters to a function?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: Passing too many parameters to a function?


  • Subject: Re: Re: Passing too many parameters to a function?
  • From: "David Leimbach" <email@hidden>
  • Date: Wed, 23 Aug 2006 15:33:20 -0700

On 8/23/06, Dave Zarzycki <email@hidden> wrote:
On Aug 20, 2006, at 3:17 AM, Uli Kusterer wrote:

>  you know how main() can be declared with varying parameter counts,
> like
>
>       int main()
>
> or
>
>       int main( int argc, const char* argv* )
>
> and even more. Does this work for any function? If I pass a function
> more parameters than it actually uses, is that safe with OS X's
> current Mach-O ABIs?

Last I knew, that was a part of the C language standard.


If you use the elipsis (...) it might even compile :-).

open, on Darwin/Mac OS X,  employs this so it can accept variable
arguments after the required ones.  see /usr/src/sys/fcntl.h around
line 393.


And it works too. Lots of Unix APIs depends on that. Off the top of my
head, the third argument of open() is optional and signal handers were
originally defined to take one argument, but now they take three. Old
handlers will obviously work, since they ignore the second and third
arguments.


Same with libc. Think "printf" :-)

Cheers,

davez
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Passing too many parameters to a function? (From: Uli Kusterer <email@hidden>)
 >Re: Passing too many parameters to a function? (From: Dave Zarzycki <email@hidden>)

  • Prev by Date: Re: Passing too many parameters to a function?
  • Next by Date: Re: Passing too many parameters to a function?
  • Previous by thread: Re: Passing too many parameters to a function?
  • Next by thread: Re: Passing too many parameters to a function?
  • Index(es):
    • Date
    • Thread