Re: Passing too many parameters to a function?
Re: Passing too many parameters to a function?
- Subject: Re: Passing too many parameters to a function?
- From: email@hidden (Peter Seebach)
- Date: Sun, 20 Aug 2006 05:20:29 -0500
In message <email@hidden>, Uli Kusterer writes:
> 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.
Only one more is particularly common (adding envp).
>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?
No.
The only thing you can safely do is call a function with the arguments it's
declared with, no more, no less. (Varargs are sort of special.)
Note that, if you declare main one of these ways, you can't call it the other.
Why can you declare it either way? Because the startup code that calls main
is specially required to know enough to be able to call it safely, somehow.
-s
_______________________________________________
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