News for hackers. Stuff that matters.
Re:C++11/14/17 Features in VS 2015 RC by pavanky on Wednesday April 29, 2015 @07:06PM (#9462403)
This may be off topic, but why are min and max macros by default ? It is the problem we face most often when we compile our library on windows.
Re:C++11/14/17 Features in VS 2015 RC by Someone on Wednesday April 29, 2015 @07:21PM (#9462475)
My guess: for backwards compatibility. I bet you also still get that oh so useful "Windows made this file for you" text file if you use a traditional Windows solution template.

For those unfamiliar with this issue: if you include Windef.h (directly or indirectly) you get what the platform provides. That file by default defines min and max macros. To prevent that, define NOMINMAX before including the windows header (in the source, or as a command line argument to the compiler). (https://support.microsoft.com/en-us/kb/143208)

Re:C++11/14/17 Features in VS 2015 RC by mmozeiko on Wednesday April 29, 2015 @07:11PM (#9462431)
Compatibility for old code? Just "#define NOMINMAX" before including windows.h
Re:C++11/14/17 Features in VS 2015 RC by StephanTLavavej on Wednesday April 29, 2015 @07:25PM (#9462491)
In fact, VS's STL has to defend itself against those macros. Since the user might have already included windows.h without NOMINMAX, what we do is parenthesize all mentions of min/max, which inhibits preprocessor expansion of function-like macros. Look at our declarations of std::min()/etc.
Re:C++11/14/17 Features in VS 2015 RC by TillE on Wednesday April 29, 2015 @07:46PM (#9462585)
> what we do is parenthesize all mentions of min/max

Oh! That explains some of the odd-looking code in <random>, since min and max are used as function names to determine the range of an RNG engine.

Re:C++11/14/17 Features in VS 2015 RC by StephanTLavavej on Wednesday April 29, 2015 @07:57PM (#9462619)
Bingo. We have a test that includes windows.h followed by all STL headers, to verify that we always remember the parens.