views:

324

answers:

3

When I use #include <d3d9.h> in my programs, I no longer need to include windows.h to use windows functions like WinMain, and CreateWindow.

Is this because d3d9.h &c. include windows.h? Mainly, I'm wondering if it is possible to substitute windows.h with d3d9.h, etc, and still be able to se any functions I could use with windows.h.

+4  A: 

Yes, if you open d3d9.h you will see # include <windows.h>.

Quintin Robinson
+1  A: 

Probably you are right: d3d9.h includes windows.h .

But for clearness dependencies in your code I 'll keep windows.h header included. Headers sageguard will help no to include windows.h file twice (as it could break the compilation unit). And If some day in the future you remove d3d9.H inclusion, the compiler will fallback to the windows.h file inclusion thus your code will still compile.

yves Baumes
+1  A: 

Any .h file you include is just a text file. Just open your 'd3d9.h' and see yourself whether it includes 'windows.h' or not.

However, even if it does include 'windows.h', it is still not a good idea to rely on that fact. If you need 'windows.h' - include it yourself. It won't do any harm. Header files are normally protected by so called "include guards", which make sure that thay are not included more than once.

AndreyT