defined min() and max() macros

  • Todor Totev

    Todor Totev - 2009-03-10

    The windows.h header checks for the macro NOMINMAX and does not define the min and max macros if it finds it. Unfortunatelly wincore.h defines them anyway and breaks havoc in out template functions. Can you please either respect this macro or define these just for Dev-C++ ?

    • David

      David - 2009-03-14

      I'll add sport for the NOMINMAX macro in the next version.

      In the meantime, if you wish to use the template version of min or max, you can specify them as follows:

      int x = std::max<int>(i,j);

      Its not a bad idea to use the template versions of min/max like this in any case, as the compiler will then provide a warning if you mistakenly compare variables of a different type.


    • David

      David - 2009-03-24

      I've elected to remove the macro definitions for min and max within Win32++, and add macros for MIN and MAX. 

      This approach has the following advantages:
      * The names don't conflict with std::min and std::max
      * They fit neatly with all supported compilers including Dev-C++ (which doesn't define min and max macros) and VS6 (which doesn't support std::min or std::max)
      * The new names are consistant with macro naming conventions
      * The change has minimal inpact on backwards compatibility. Only Dev-C++ users will be affected, and they can use MIN/MAX in place of min/max.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks