-
NULL parameters
Why the heck does Win32 programming have so many parameters that are always supposed to be declared NULL? I mean - why don't compiler makers just say "well, we know it's going to be NULL, since the program won't compile if it isn't, so why don't we just leave that parameter out?"
-
Any examples ? Apart from those reserved DWORDS, I don't remember anything that would require NULL arguments... for anything but my own lazyness ;)
-
-
I would guess that all thos NULL parameters actually do have a function to fill about once every 10 year. In most books I been reading it just says." The third parameter is set to NULL" and no more explonation about why or what other options there is. Or else they might be there for future use and they later decide not to develop the function any further. The question is why don't they supply an overloaded function for the day to day use.
-
That depends on the operating system. In some systems, i.e. 9x or CE, those parameters have no meaning, because the system model is different.
MSDN for CreateThread in general:
lpThreadAttributes
[in] Pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpThreadAttributes is NULL, the handle cannot be inherited.
Windows NT/2000/XP: The lpSecurityDescriptor member of the structure specifies a security descriptor for the new thread. If lpThreadAttributes is NULL, the thread gets a default security descriptor.
</MSDN>
Which probably means that you have to pass NULL for all 95/98/ME/CE systems, as they don't support the security descriptor model for threads ( or anything else for that matter ).
;-)
-
So it'd just be because MS decided to use a set group of fuctions, and didn't want to use a different type of CreateThread() (or whatever) for different versions of Windows?
-
Yes. And you can compile your code for all versions. After all, NULL is a valid default for all, so you don't need to change your code if your target system changes.
-
Only reason I could imagine if for is for future updates to the API that it would be convenient to already have the param there and know it, now they will just implement it.
My $0.02