Reputation: 161
#include <Windows.h>
#define WIN32_LEAN_AND_MEAN
Why the above code statement has mistake? Is the order wrong or others?
Upvotes: 0
Views: 4270
Reputation: 634
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
#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 */
Directly from Windows.h
Upvotes: 6
Reputation: 281515
The order is wrong. WIN32_LEAN_AND_MEAN
affects what windows.h
declares, so it needs to be defined before windows.h
is included:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
Upvotes: 4