• 12
• 12
• 9
• 10
• 13

# Not including windows.h ??

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am using the windows QueryPerformanceCount() function (something like that, cant remember exact name) to maintain movement and momentum of things in my app .... anyways, the point is, it adds like ~600KB to my app! thats huuuuuuuuuge im my opinion :-D As I can remember, VB has a way of making a call to these kind of functions without importing all the stuff? (I'm an extreme newb) Is there a way of me utalising this function without bloating my app by including windows.h ? (again, I think it was windows.h)

##### Share on other sites
this may be a silly (albeit obvious) question: is it a debug or release build? debug builds usually incur a HUGE amount of file size increment especially when u include windows.h. Try the release build if u havent already.

but... if u're already using release.. er.. ignore this :P

##### Share on other sites
I'm using Dev-C++ and I dont think there is a debug build. Or there might be, but if there is I havent intentionally used it, ever :-)

##### Share on other sites
QueryPerformanceCounter is defined in winbase.h, so you could just include that. Of course, to get it to compile, you would also have to include stdarg.h and windef.h (in that order I think). This would drop your size by quite a bit, because you would not be including the majority of windows.h.

To do it without including anything, you would have to construct the call itself. it would look like:
 BOOL __stdcall QueryPerformanceCounter(PLARGE_INTEGER);

Of course...that would mean you would have to copy the typedef _LARGE_INTEGER from winnt.h ... which would require the definition of DWORD and LONG ... etc. This could be done with not too much more trouble, but would be considerably easier to just include the three files listed above.

You know, this is just like the decision whether to work in c++ or c. If you don't mind a little overhead, you will not have to do everything yourself. Thats the tradeoff you are looking at. Your choice how far you want to take it though.

##### Share on other sites
I might just do that :-) Thanks.

##### Share on other sites
Take a look at the good old glut.h. (I know glfw replaced glut somehow but that's another issue.) This might show you a good example on how to remove the windows.h depedency. Well this depends on which defs, you need. Just find in files for the defs and see what you need to rewrite.

##### Share on other sites
Actually, I'm using SDL at the moment, which has a timer of some sorts, but I used the windows one because I found the Win one before the SDL one (tutorial).

I guess for now I'll expect the app to be huge, that way when I incorporate the SDL based timer it will shrink and I'll be happy :-)

##### Share on other sites
#define WIN32_LEAN_AND_MEAN before you include windows.h supposedly reduces the amount of extra stuff that gets added to your program.

##### Share on other sites
Quote:
 Original post by xyuriActually, I'm using SDL at the moment, which has a timer of some sorts, but I used the windows one because I found the Win one before the SDL one (tutorial).I guess for now I'll expect the app to be huge, that way when I incorporate the SDL based timer it will shrink and I'll be happy :-)

Hmm you probably missed my point. I was maybe not totally clear, but I did not tell you to include glut.h ! But to look at how they do to remove windows.h and redefine what they need of the windows definitions and only those definitions.

##### Share on other sites
Ahhhhh, now I get you :-)

I'm very n00b and will have difficulty sifting through that header to find how they did it, but I'll definately try :-)

Thanks mate