Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing too many parameters to a function?



In message <email@hidden>, Dave Zarzycki writ
es:
>Last I knew, that was a part of the C language standard.

It is not.  There is no guarantee that you can pass extra arguments safely.

There is a special guarantee about the calling arguments of main; the startup
code has to magically Do The Right Thing.

>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.

Both of those are POSIX, rather than C.  The third argument to open isn't
optional; it's new, but calls without it are treated just like calls with it,
where the third argument is, well, whatever happens to be handy.  Maybe a
bit of stack, maybe a scratch register.  No guarantees!

With signals, the arguments are passed, but old code that doesn't check for
them will probably compile correctly; there's no guarantee, and you can't
make a program that does this without invoking undefined behavior somewhere.

-s
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden

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



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.