NULL parameters

This is a discussion on NULL parameters within the Windows Programming forums, part of the Platform Specific Boards category; Why the heck does Win32 programming have so many parameters that are always supposed to be declared NULL? I mean ...

  1. #1
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825

    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?"

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    Any examples ? Apart from those reserved DWORDS, I don't remember anything that would require NULL arguments... for anything but my own lazyness
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    591
    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.

  5. #5
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    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 ).

    ;-)
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  6. #6
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    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?

  7. #7
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    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.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  8. #8
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    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
    1978 Silver Anniversary Corvette

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help Debugging my AVL tree program.
    By Nextstopearth in forum C Programming
    Replies: 2
    Last Post: 04-04-2009, 02:48 AM
  2. Tweakable Radar...
    By DoraTehExploda in forum Game Programming
    Replies: 8
    Last Post: 06-07-2005, 11:49 AM
  3. . . . . . . - . . . - -
    By The Brain in forum C++ Programming
    Replies: 17
    Last Post: 05-17-2005, 05:01 AM
  4. button 'message'
    By psychopath in forum Windows Programming
    Replies: 12
    Last Post: 04-18-2004, 10:57 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21