C++ + Visual Studio 2012 (VS2012) + Win8 , converting projects up some conflicts I found

Having loved the ability to compile VS2010 projects inside the VS2012 shell as a way of delaying the update, I thought it was time to stop delaying ( 1 Year late ).

std::cout << "Minimum value for int: " << std::numeric_limits<int>::min() << std::endl;
std::cout << "Maximum value for int: " << std::numeric_limits<int>::max() << std::endl;

Generates error:

error C2059: syntax error : '::' [path]\source.cpp

There is a good chance if you have these lines and are including the windows header you will hit an error. The Windows team put in a solution to the #define min conflict in <minwindef.h>.

So instead of

#include <windows.h>

You use a #define to avoid this

#define NOMINMAX
#include <windows.h>

Another issue I found was with an annoying char define, again from the Windows team in <rpcndr.h>.

#define small char

This one doesn’t have the ability to comment out for so if you have a small function with something like:

AnObj small = large.resize(val);

Generates error:

error C2628:'AnObj' followed by 'char' is illegal (did you forget a ';'?) [path]\source.cpp

You will have to suffer and change the name, in some ways it teaches you (me) for not being very specific, still annoying though. Hopefully this is all the conversion errors I’ll hit.

Posted by Stuart James Sunday, May 12, 2013 4:13:00 PM Categories: API C++ Visual Studio Windows8
Stuart James