windows #defining WIN32_LEAN_AND_MEAN 究竟排除了什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11040133/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does #defining WIN32_LEAN_AND_MEAN exclude exactly?
提问by fishfood
I found the explanation defining WIN32_LEAN_AND_MEAN "reduces the size of the Win32 header files by excluding some of the less frequently used APIs". Somewhere else I read that it speeds up the build process.
我发现定义 WIN32_LEAN_AND_MEAN 的解释“通过排除一些不太常用的 API 来减小 Win32 头文件的大小”。我在其他地方读到它加快了构建过程。
So what does WIN32_LEAN_AND_MEAN exclude exactly? Should I care about this pre-processor directive? Does it speed up the build process?
那么 WIN32_LEAN_AND_MEAN 究竟排除了什么?我应该关心这个预处理器指令吗?它会加快构建过程吗?
I've also seen a preprocessor directive in projects named something along the lines of extra lean. Is this another esoteric preprocessor incantation I should know about?
我还在项目中看到了一个预处理器指令,它以额外精益的方式命名。这是我应该知道的另一个深奥的预处理器咒语吗?
采纳答案by CuriousGeorge
Directly from the Windows.h header file:
直接来自 Windows.h 头文件:
#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 */
if you want to know what each of the headers actually do, typeing the header names into the search in the MSDNlibrary will usually produce a list of the functions in that header file.
如果您想知道每个头文件的实际用途,在MSDN库中的搜索中键入头文件名称通常会生成该头文件中的函数列表。
Also, from Microsoft's support page:
此外,来自微软的支持页面:
To speed the build process, Visual C++ and the Windows Headers provide the following new defines:
VC_EXTRALEAN
WIN32_LEAN_AND_MEANYou can use them to reduce the size of the Win32 header files.
为了加快构建过程,Visual C++ 和 Windows 头文件提供了以下新定义:
VC_EXTRALEAN
WIN32_LEAN_AND_MEAN您可以使用它们来减小 Win32 头文件的大小。
Finally, if you choose to use either of these preprocessor defines, and something you need is missing, you can just include that specific header file yourself. Typing the name of the function you're after into MSDN will usually produce an entry which will tell you which header to include if you want to use it, at the bottom of the page.
最后,如果您选择使用这些预处理器定义中的任何一个,并且缺少您需要的某些内容,您可以自己包含该特定头文件。在 MSDN 中键入您要查找的函数的名称通常会在页面底部生成一个条目,如果您想使用它,该条目将告诉您要包含哪个标题。
回答by Chris911
According the to Windows Dev CenterWIN32_LEAN_AND_MEAN excludes APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets.
根据Windows Dev Center,WIN32_LEAN_AND_MEAN 不包括密码学、DDE、RPC、Shell 和 Windows 套接字等 API。