它是重新创建的Win32的头一个好主意? [英] Is it a good idea to recreate Win32's headers?

查看:81
本文介绍了它是重新创建的Win32的头一个好主意?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现自己做对的Win32以上C / C ++ code最近,从一个C#背景的我已经开发了以干净code是完全一致的,因此,从搬走的痴迷漂亮的系统。*命名空间中回到#define语句组成的Win32 API头文件的混杂是一个有点文化冲击。

I'm finding myself doing more C/C++ code against Win32 lately, and coming from a C# background I've developed an obsession with "clean code" that is completely consistent, so moving away from the beautiful System.* namespace back to the mishmash of #defines that make up the Win32 API header files is a bit of a culture shock.

通过MSDN的按字母顺序排列的核心Win32函数列表看完后,我意识到的Win32 API的设计其实是多么简单,这是不幸的,它与过去25年所有的克鲁夫特笼罩,其中包括16位编程是完全多次提到不相干的在今天的64位世界。

After reading through MSDN's alphabetical list of core Win32 functions I realised how simple Win32's API design actually is, and it's unfortunate that it's shrouded with all the cruft from the past 25 years, including many references to 16-bit programming that are completely irrelevant in today's 64-bit world.

我工作即将开始一个新的C / C ++项目,我在想,我怎么能重新创建需要的基础上的Win32的头。我可以设计它是美丽的,但它会保持与现有程序100%的二进制文件(和源)的兼容性(因为#define语句最终解决同样的事情)。

I'm due to start a new C/C++ project soon, and I was thinking about how I could recreate Win32's headers on an as-needed basis. I could design it to be beautiful, and yet it would maintain 100% binary (and source) compatibility with existing programs (because the #defines ultimately resolve the same thing).

我想知道是否有人在过去这未遂(谷歌却一无所获),或者如果有人想从中劝阻我。

I was wondering if anyone had attempted this in the past (Google turned up nothing), or if anyone wanted to dissuade me from it.

我想到另一件事,就是如何用清洁Ç的Win32 API,可以设计在顶部有一个更清洁和更容易使用C ++的Win32 API的包装,因为不会从旧的C的Win32的命名空间污染项目。

Another thing I thought of, was how with a cleaner C Win32 API, it becomes possible to design a cleaner and easier to use C++ Win32 API wrapper on top, as there wouldn't be any namespace pollution from the old C Win32 items.

编辑:

只是为了澄清,我不是这样做是为了提高编译性能或任何种类的优化,我充分认识到编译器摒弃了未使用的一切。在这里,我的任务是有一个Win32头库,是一个很高兴一起工作(因为我不需要每次使用函数时脱preSS大写锁定)。

Just to clarify, I'm not doing this to improve compilation performance or for any kind of optimisation, I'm fully aware the compiler does away with everything that isn't used. My quest here is to have a Win32 header library that's a pleasure to work with (because I won't need to depress Caps-lock every time I use a function).

推荐答案

别这样做。

这是可能的,但这需要很长的时间,可能会导致微妙的错误。

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

但是,更重要的是,它会使你的程序根本不可能为其他比你要保持任何人。

However, and more importantly, it will make your program utterly impossible for anyone other than you to maintain.

这篇关于它是重新创建的Win32的头一个好主意?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆