Re: Passing too many parameters to a function?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com In message <36855455-21CD-46C2-9D0E-D9F1D263092C@apple.com>, 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
seebs@plethora.net