<p>I'm seeing strange errors when my C++ code has min() or max() calls. I'm using Visual C++ compilers.</p>

[{'answer_id': 14169, 'author': 'Ashwin Nanjappa', 'author_id': 1630, 'author_profile': 'https://Stackoverflow.com/users/1630', 'pm_score': 5, 'selected': True, 'text': '<p>Check if your code is including the <strong>windows.h</strong> header file and either your code or other third-party headers have their own <strong>min()</strong>/<strong>max()</strong> definitions. If yes, then prepend your <strong>windows.h</strong> inclusion with a definition of <strong>NOMINMAX</strong> like this:</p>\n\n<pre><code>#define NOMINMAX\n#include &lt;windows.h&gt;\n</code></pre>\n'}, {'answer_id': 14177, 'author': 'Pat Notz', 'author_id': 825, 'author_profile': 'https://Stackoverflow.com/users/825', 'pm_score': 0, 'selected': False, 'text': '<p>Ugh... scope it, dude: <code>std::min()</code>, <code>std::max()</code>.</p>\n'}, {'answer_id': 14195, 'author': 'Orion Edwards', 'author_id': 234, 'author_profile': 'https://Stackoverflow.com/users/234', 'pm_score': 0, 'selected': False, 'text': "<p>I haven't used it in years but from memory boost assigns min and max too, possibly?</p>\n"}, {'answer_id': 24150, 'author': 'itj', 'author_id': 888, 'author_profile': 'https://Stackoverflow.com/users/888', 'pm_score': 2, 'selected': False, 'text': '<p>Another possibility could be from side effects.  Most min/max macros will include the parameters multiple times and may not do what you expect.  Errors and warnings could also be generated.\n<PRE>\nmax(a,i++) expands as ((a) > (i++) ? (a) : (i++))</p>\n\n<p>afterwards i is either plus 1 or plus 2\n</PRE>\nThe () in the expansion are to avoid problems if you call it with formulae.  Try expanding max(a,b+c)</p>\n'}, {'answer_id': 1793313, 'author': 'dhorn', 'author_id': 148632, 'author_profile': 'https://Stackoverflow.com/users/148632', 'pm_score': -1, 'selected': False, 'text': '<p>Honestly, when it comes to min/max, I find it best to just define my own:</p>\n\n<pre><code>#define min(a,b) ((a) &lt; (b) ? (a) : (b))\n#define max(a,b) ((a) &gt;= (b) ? (a) : (b))\n</code></pre>\n'}, {'answer_id': 4783177, 'author': 'MSalters', 'author_id': 15416, 'author_profile': 'https://Stackoverflow.com/users/15416', 'pm_score': 2, 'selected': False, 'text': "<p>Since Windows defines this as a function-style macro, the following workaround is available:</p>\n\n<pre><code>int i = std::min&lt;int&gt;(3,5);\n</code></pre>\n\n<p>This works because the macro <code>min()</code> is expanded only when <code>min</code> is followed by <code>(</code>, and not when it's followed by <code>&lt;</code>.  </p>\n"}]
['https://Stackoverflow.com/questions/14165', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1630/']