Dan*_*ing 6 c++ gcc rounding c++98
有没有一个很好的理由为什么这个程序在GCC下编译,即使使用-ansi和-pedantic标志?
#include <cmath>
int main (int argc, char *argv [])
{
double x = 0.5;
return static_cast<int>(round(x));
}
Run Code Online (Sandbox Code Playgroud)
用它来编译干净(没有警告,甚至)g++ -ansi -pedantic -Wall test.cpp -o test.
我看到两个问题:
round() 在ISO-conformant模式下不应该对C++可用(因为它来自C99)round()在这种情况下可用,它也应该只是std命名空间我错了吗?