Monday, September 18, 2017

Digest for comp.lang.c++@googlegroups.com - 2 updates in 1 topic

Manfred <noname@invalid.add>: Sep 18 12:56PM +0200

On 9/17/2017 8:30 PM, Öö Tiib wrote:
 
> Somehow the authors of your package have managed to do same stupid
> thing that Microsoft did. Microsoft did so that the windows.h declared
> macros named "min" and "max" and so standard library did not work.
 
Agreed with the opinion about MS macros
 
> define macros min and max. However Microsoft's own headers like
> gdiplus.h used those min and max macros and so more clever solution
> was needed.
 
There is a trick for this:
#include <algorithm>
(std::min)(17, 29)
 
https://social.msdn.microsoft.com/Forums/vstudio/en-US/9b83c008-7bfc-483d-9395-959d4ccefff6/vs-10-where-is-cppmax-and-cppmin-or-equivalent?forum=vcgeneral
 
(It works with MSVC, never used with gcc)
 
Kan <fcantoro@nospam.it>: Sep 18 02:33PM +0200

Il 18/09/2017 12:56, Manfred ha scritto:
> (std::min)(17, 29)
 
> https://social.msdn.microsoft.com/Forums/vstudio/en-US/9b83c008-7bfc-483d-9395-959d4ccefff6/vs-10-where-is-cppmax-and-cppmin-or-equivalent?forum=vcgeneral
 
> (It works with MSVC, never used with gcc)
 
Yes, but however you still have problems with other calls like
std::numeric_limits<T>::min(), so in this case I solved writing:
 
#include <Windows.h>
#undef min
#undef max
#include <algorithm>
 
Then use std::min and std::max instead on min and max.
Otherwise, if you really don't want to change the source code:
using std::min;
using std::max;
 
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: