In one of the answers to this question jalf spoke about useful define NOMINMAX
, that could prevent from unwanted defining min/max macros. Are there other useful defines that can help to control windows.h
(or other Windows headers, for instance Microsoft C Runtime headers or STL implementation) behavior?
Asked
Active
Viewed 6,856 times
22

Community
- 1
- 1

Kirill V. Lyadvinsky
- 97,037
- 24
- 136
- 212
-
5Ugh. I wasted half an hour on this nonsense of min and max on win32 platform. – Tim Dec 17 '09 at 01:30
2 Answers
33
The most commonly used is probably WIN32_LEAN_AND_MEAN
- it disables rarely used parts of the API. You can find more on MSDN's Using the Windows Headers.
I remembered wrong about MSDN listing those defines, so here's list from windows.h:
/* If defined, the following flags inhibit definition
* of the indicated items.
*
* NOGDICAPMASKS - CC_*, LC_*, PC_*, CP_*, TC_*, RC_
* NOVIRTUALKEYCODES - VK_*
* NOWINMESSAGES - WM_*, EM_*, LB_*, CB_*
* NOWINSTYLES - WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_*
* NOSYSMETRICS - SM_*
* NOMENUS - MF_*
* NOICONS - IDI_*
* NOKEYSTATES - MK_*
* NOSYSCOMMANDS - SC_*
* NORASTEROPS - Binary and Tertiary raster ops
* NOSHOWWINDOW - SW_*
* OEMRESOURCE - OEM Resource values
* NOATOM - Atom Manager routines
* NOCLIPBOARD - Clipboard routines
* NOCOLOR - Screen colors
* NOCTLMGR - Control and Dialog routines
* NODRAWTEXT - DrawText() and DT_*
* NOGDI - All GDI defines and routines
* NOKERNEL - All KERNEL defines and routines
* NOUSER - All USER defines and routines
* NONLS - All NLS defines and routines
* NOMB - MB_* and MessageBox()
* NOMEMMGR - GMEM_*, LMEM_*, GHND, LHND, associated routines
* NOMETAFILE - typedef METAFILEPICT
* NOMINMAX - Macros min(a,b) and max(a,b)
* NOMSG - typedef MSG and associated routines
* NOOPENFILE - OpenFile(), OemToAnsi, AnsiToOem, and OF_*
* NOSCROLL - SB_* and scrolling routines
* NOSERVICE - All Service Controller routines, SERVICE_ equates, etc.
* NOSOUND - Sound driver routines
* NOTEXTMETRIC - typedef TEXTMETRIC and associated routines
* NOWH - SetWindowsHook and WH_*
* NOWINOFFSETS - GWL_*, GCL_*, associated routines
* NOCOMM - COMM driver routines
* NOKANJI - Kanji support stuff.
* NOHELP - Help engine interface.
* NOPROFILER - Profiler interface.
* NODEFERWINDOWPOS - DeferWindowPos routines
* NOMCX - Modem Configuration Extensions
*/

Cat Plus Plus
- 125,936
- 27
- 200
- 224
-
Link leads to the article which mention only WIN32_LEAN_AND_MEAN. Wrong link? – Kirill V. Lyadvinsky Sep 08 '09 at 16:31
-
Hm, I though it lists NOxxx defines. I'll edit my answer to include that list. – Cat Plus Plus Sep 08 '09 at 16:36
-
The article also says to look in windows.h for more macros. ("For a list of support NOapi symbols, see Windows.h") I don't think there is any complete reference documentation. – jalf Sep 08 '09 at 16:37
-
Well, that comment is apparently the only one. I could swear I saw this on MSDN somewhere, though. – Cat Plus Plus Sep 08 '09 at 16:39
-
1This isn't a list of useful defines, it's a list of `NOXXX` defines. Most are useless. And `STRICT` isn't listed... – user541686 Apr 30 '21 at 01:14
-
A few more: #define NOCRYPT #define NOTAPE #define NOIMAGE #define NOPROXYSTUB #define NORPC – Thief Aug 31 '23 at 09:52
6
MFC projects can use VC_EXTRALEAN
since WIN32_LEAN_AND_MEAN
is already defined by MFC. I also recommend enabling STRICT.

user7116
- 63,008
- 17
- 141
- 172