我创建了一个空白的Win32 C ++项目。即使我包含math.h或cmath库,编译器也会继续为round函数提供C3861未定义的错误。
我试过以下
1. adding the /TC compile as C++ and using cmath
2. adding the include _MATH_DEFINES_DEFINED
答案 0 :(得分:0)
您是否想要转到int?
std::round()
不返回int值,
而不是尝试:
int a = int(std::floor(var + 0.5));
答案 1 :(得分:0)
Visual Studio 2012(MSVC 11.0)并不严格遵循C ++ 11,因此它可能没有std :: round。
使用
inline double round(double value) { return value < 0 ? -std::floor(0.5 - value) : std::floor(0.5 + value); }
// analogously for float