is uising windows.h bad? not efficient?

I had been using C language for sometime and now i want to do some work in C++ &
Windows for doing some tests with directX and OpenGL...

i need them to be efficient..

i remember i saw somewhere that using windows.h header slows your program because it contains lots of code ( of course i can imagine that there are thousands of things in the windows API )

Is using windows.h very un-efficient?
OR is there any other way that i can create a window/GUI in windows with C++ ( it better be Open Source and work with newer win versions )

does all those games out there for windows use this header....

i am very new to windows programing...

Thank You.. :)
i remember i saw somewhere that using windows.h header slows your program because it contains lots of code


That's completely untrue.

Including a header does nothing but increase compile time.

The only thing that could really make your program slower is if you execute more code. Including a header doesn't execute any code.

is there any other way that i can create a window/GUI in windows with C++ ( it better be Open Source and work with newer win versions )


There are several GUI toolkits. I prefer using them over WinAPI (windows.h) because they're easier and often cross platform. Two of the most popular are wxWidgets and Qt (you can google them to find more).

However if you're looking to be as fast and efficient as possible, then using WinAPI directly is probably the way to go, as other GUI toolkits will be using WinAPI under the hood anyway, and will add their own overhead on top of that.



Though really, you shouldn't worry so much about such things. Programs are usually slowed down more by what they do then what toolkit they use. Try writing a program first, and worry about making it faster if it's slow (note it probably won't be slow).
Think about it this way, if you had to rewrite EVERYTHING in the windows.h file to work exactly as it does now would you be able to do a better job? Would it even be worth your time? Like Disch said it won't slow the execution of your code, so what other metric are you using to measure effecency?

You'll always see tons of fanboys and hipsters bashing on the Win32 API. But when it comes down to learning and using the code, Windows beats the living hell out of *nix. You will not find a better resources and documentation for *nix then MSDN has for Windows at the same price.

EDIT: I also wanted to add that I wanted to believe what people said, that Linux was the future and that development on it was just as easy or easier then on windows. It simply isn't true, the documentation isn't out there.
Last edited on
development on it was just as easy or easier then on windows.

It wouldn't say it's easier, but I could agree with the "just as easy" part.

It simply isn't true, the documentation isn't out there.

But it is. All relevant libraries have extensive documentation. The only time where I had some problems was with the Xlib documentation, which is not as verbose on some things as I would have liked it. Then again, that's probably because hardly anyone needs to use Xlib directly these days and so no one particularly cares about improving the documentation for a potentially dying library.

Then again, that's probably because hardly anyone needs to use Xlib directly these days and so no one particularly cares about improving the documentation for a potentially dying library.


You know, in my limited forays into Linux coding about the only thing I liked was XLib. The man pages seemed to give decent function descriptions.

Getting back to the original poster though, I'd have to say I'd encourage direct use of the Windows Api (using Windows.h) for Windows programming. Your basic Hello, World! GUI skeleton is less than 10K, which is pretty small by today's standards. So yea, its efficient.
That's one thing about wxWidgets -- it's executables are huge. No way you're getting 10K in any wx program.

But again it depends where your priorities lie. I personally like the ease and portability of GUI toolkits, but if speed and small exe sizes are more important to you, then definitely go WinAPI.
i would think that sence the windows heder is not so sufishunt.
simply b'cus its the bigest heder out there... that i know of.

i would think that sence the windows heder is not so sufishunt.
simply b'cus its the bigest heder out there... that i know of.


No, its just as Disch said, using Windows.h won't increase the size of your executable, make it run slower, or anything like that. Windows is in my opinion an extremely advanced system, and for that reason it takes a lot of function prototypes, defines, structures, etc., to adequately describe it. Windows.h is actually the master include which pulls in many, many, many, other includes. But everything not referenced in your actual code is excluded from your executable.

Let me just give you an idea of what's possible. Where I work all our mission critical software consists of about three executable programs whose combined size comes to about one megabyte. That's 1 MB. One million bytes, i.e., it would fit on an old 1.44 MB floppy disk. The source code comes to probably about 30,000 lines of code I've written, but that doesn't include much more than that I didn't write but is in the system includes, i.e., Windows.h, etc. These are major systems that before I wrote them ran only on mainframes.

The reason the programs are so small is that most of their functionality comes directly from code that is a part of every Windows system. Contrast this with class frameworks (.NET, MFC, wxWidgets, etc) which consist of OOP class wrappers around the base system functionality implemented in a required runtime, and you have the difference. To each his own. It depends on what you want or what you know or what you can put up with.

My programs are not cross platform. They will only run on Windows. They were written for Windows. If I wanted to write a *nix program I'd use XLib or GTK likely.
ty98 wrote:
i would think that sence the windows heder is not so sufishunt.
simply b'cus its the bigest heder out there... that i know of.


You might find this site useful:

http://www.dictionary.com
Thanks everyone :)
Just to clarify, freddie1 is describing DLL's when he says
...code that is part of every Windows system.
Topic archived. No new replies allowed.