c++ - Why round() is known by mingw but not by visual studio compiler -


sample code valid , gets compiled gcc not vs compiler:

#include <cmath>  int main() {     float x = 1233.23;     x = round (x * 10) / 10;     return 0; } 

but reason, when compiling in visual studio error:

c3861: 'round': identifier not found 

i include cmath suggested here: http://www.daniweb.com/software-development/cpp/threads/270269/boss_loken.cpp147-error-c3861-round-identifier-not-found

is function in gcc only?

first of all, cmath not guaranteed bring round global namespace, code fail, up-to-date, standards compliant c or c++ implementation. sure, use std::round (or #include <math.h>.)

note c++ compiler must support c++11 std::round (<cmath>). c compiler should support c99 round (from <math.h>.) if version of msvc doesn't work after fix suggested, that particular version pre-c++11, or not standards compliant.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -