C++ 关于编译期的优化处理

C++ 关于编译期的优化处理

一、#define WIN32_LEAN_AND_MEAN 的作用

1:为什么要 #define WIN32_LEAN_AND_MEAN 。答案很简单,因为要包含尽量精简的内容,包含了这一句编译的时候明显快多了。

2:不加载MFC所需的模块。如果你的工程不使用MFC,就加上这句,这样一来在编译链接时,包括最后生成的一些供调试用的模块时,速度更快,容量更小。

3:我想这个不是 MFC 特有的, WIN32_LEAN_AND_MEAN 是针对 Win32 相关的头文件的, 比如在包含 WIN32/MFC SDK 头文件之前定义些宏, 可以通过预处理来关闭掉一些不太常用的系统接口或参数, 这样可以加快编译的速度!你可以看看 Windows.h 文件里和 WIN32_LEAN_AND_MEAN 相关的部分就明白了, 另外在这个文件开始部分一个注释, 这里有很多更详细的控制开关(宏)

原文链接:#define WIN32_LEAN_AND_MEAN 的作用

In the Windows.h header, if WIN32_LEAN_AND_MEAN is not defined, the preprocessor will includes other headers. So if you want to not include theses headers, you must define WIN32_LEAN_AND_MEAN before #include , else it won’t have any effects

译:在Windows.h头文件中,如果未定义WIN32_LEAN_AND_MEAN,则预处理器将包含其他头文件。 因此,如果您不想包含这些头文件,则必须在#include(这些头文件)之前定义WIN32_LEAN_AND_MEAN,否则(在#include那些头文件之后定义WIN32_LEAN_AND_MEAN)将不会有任何效果

#ifndef WIN32_LEAN_AND_MEAN
#include <cderr.h>
#include <dde.h>
#include <ddeml.h>
#include <dlgs.h>
#ifndef _MAC
    #include <lzexpand.h>
    #include <mmsystem.h>
    #include <nb30.h>
    #include <rpc.h>
#endif
#include <shellapi.h>
#ifndef _MAC
    #include <winperf.h>
    #include <winsock.h>
#endif
#ifndef NOCRYPT
    #include <wincrypt.h>
    #include <winefs.h>
    #include <winscard.h>
#endif

#ifndef NOGDI
    #ifndef _MAC
        #include <winspool.h>
        #ifdef INC_OLE1
            #include <ole.h>
        #else
            #include <ole2.h>
        #endif /* !INC_OLE1 */
    #endif /* !MAC */
    #include <commdlg.h>
#endif /* !NOGDI */
#endif /* WIN32_LEAN_AND_MEAN */

二、持续补充中,欢迎大佬指点

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值