Is it a good idea to recreate Win32 headers?

I find that I have been doing more C / C ++ code against Win32 recently, and based on the C # background, I developed an obsession with "clean code" that is fully consistent, so move away from the beautiful System space. * returning to mishmash from the #defines that make up the Win32 API header files has a small effect on culture.

After reading the MSDN in the alphabetical list of the main Win32 functions, I realized how simple the Win32 API design really is, and this, unfortunately, has been shrouded in all the torsion from the past 25 years, including many links to 16-bit programming that are completely irrelevant in today's 64 bit world.

I should start a new C / C ++ project soon, and I was thinking about how I can recreate Win32 headers as needed. I could design it as beautiful, and yet it would maintain 100% binary (and source) compatibility with existing programs (because #defines ultimately allows the same thing).

I was wondering if anyone tried to do this in the past (Google didnโ€™t show anything), or if someone wanted to dissuade me from him.

Another thing I was thinking about was how, with the help of a cleaner C Win32 API, it becomes possible to develop a cleaner and more user-friendly C ++ Win32 API shell, since there would be no pollution of the namespace from the old Win32 C elements.

EDIT:

To clarify, I do not do this to improve compilation performance or for any optimization, I fully understand that the compiler eliminates everything that is not used. My quest here is to have a Win32 header library that is nice to work with (because I wonโ€™t have to block the caps-lock every time I use the function).

+7
source share
6 answers

Do not do this.

It may be possible, but it will take a long time and will probably lead to subtle errors.

However, more importantly, it will make your program completely impossible for anyone but you.

+10
source

There is no point in doing this. Just because the extra crack does not mean that it is compiled into a binary file (all unused ones will be optimized). In addition, on EXTREME, regardless of the fact that something will change (I donโ€™t know, maybe WM_INPUT number of changes), it is much easier to use system headers. Also, what is more intuitive? I think #include <windows.h> much easier to understand than #include "a-windows-of-my-own.h" .

Also, honestly, you never have to even look at the contents of windows.h. Yes, I read it, yes, it is ugly as a sin, but it does what I need, and I do not need to support it.

Probably the only drawback to using real windows.h is that it MAY slow down compilation by a few milliseconds.

+3
source

Not. What is the point? Just turn on <windows.h> and define some macros such as WIN32_LEAN_AND_MEAN , VC_EXTRALEAN , NOGDI , NOMINMAX , etc., to shorten what you don't need / need to speed up compilation time.

+3
source

Although Win32 headers may be considered dirty, you should almost never (or want) to look into them. Everything you need to know is described in the Win32 SDK. The exact contents of the header files is an implementation detail.

There is a ton of things out there that will take a lot of time and replicate too thinly, especially in relation to different versions of Win32 SDK.

I recommend:

 #include <windows.h> 
+3
source

In my opinion, this is bad practice. Cleanliness and brevity are achieved due to the maximum possible adherence to standard practice and the maximum possible use of the platform. You must assume that Microsoft will gain full experience in its own platform, and some aspects will go beyond what you know now. In simple words, this is their product, and they know better.

How much yourself:

  • ... you are disconnecting from the Microsoft API, so Microsoft can no longer deliver updates to you through its standard channels.
  • ... you can introduce errors because of your own pride, feeling that you understand something until you have
  • ... you would spend a lot of time on the lack of tangible benefits (since C headers do not transfer overhead to compiled binaries)
  • ... you end up creating a project that is less elegant.

The most elegant code is one that contains more LOCs of actual program logic and as little LOC as possible for "household" (that is, code not directly related to the task). Take the time to use the Platform SDK headers to make your project more elegant.

+2
source

This has been done in the past.

In its include directory, MinGW contains its own version of windows.h . Presumably this exists for the headers to work with gcc. I do not know if it will work with the Microsoft compiler.

+1
source

All Articles