Build errors "min/max is not a member of std"

I’m trying to build cocos2d-x but am having no luck due to a few errors that I cannot solve. I’ve googled around and searched the forum but it appears as though nobody else has had this error before, so I assume I must be missing something or doing something wrong.

I’ve tried building both v2.1.5 as well as the v3.0 alpha, and both give the same errors. I’ve tried with Visual Studio 2012 on a Windows 8 machine as well as Visual Studio 2010 on a Windows 7 machine. Again, same errors.

I have also removed all of the JavaScript and Lua projects from the solution (including the libs and the samples), but that made no difference. Still the same errors.

Here are the errors from the Visual Studio error list when trying to build v3.0 alpha (same errors with v2.1.5 too). Note the numbers at the front are the line numbers in the ccgeometry.cpp file.

85 error C2039: ‘min’ : is not a member of ‘std’ ccgeometry.cpp
86 error C3861: ‘min’: identifier not found ccgeometry.cpp
87 error C2039: ‘max’ : is not a member of ‘std’ ccgeometry.cpp
88 error C3861: ‘max’: identifier not found ccgeometry.cpp
89 error C2039: ‘max’ : is not a member of ‘std’ ccgeometry.cpp
90 error C3861: ‘max’: identifier not found ccgeometry.cpp
91 error C2039: ‘min’ : is not a member of ‘std’ ccgeometry.cpp
92 error C3861: ‘min’: identifier not found ccgeometry.cpp

Can anyone please point me in the right direction?

On a side note, I also get 538 warnings… is that normal?

I had a similar problem, although in different files, when I moved to MSVC Express 2013 while using Cocos2d-x-2.2. You can find some solutions here

it requires the header.

Wrap it in the round brackets, e.g.

(std::min)(value_0, value_1);