我是使用emscripten的新手,在编译cpp文件时遇到错误。
我有iae.cpp:
bool IsAlmostEqual(double A, double B)
{
//http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
long long aInt = reinterpret_cast<long long&>(A);
if (aInt < 0) aInt = -9223372036854775808LL - aInt;
long long bInt = reinterpret_cast<long long&>(B);
if (bInt < 0) bInt = -9223372036854775808LL - bInt;
return (std::abs(aInt - bInt) <= 10000);
}
我尝试使用emscripten编译它:
emcc iae.cpp
但它会产生以下警告和错误:
INFO root: (Emscripten: Running sanity checks)
WARNING root: java does not seem to exist, required for closure compiler. -O2 and above will fail. You need to define JAVA in ~/.emscripten
iae.cpp:5:27: warning: integer constant is so large that it is unsigned
if (aInt < 0) aInt = -9223372036854775808LL - aInt;
^
iae.cpp:7:27: warning: integer constant is so large that it is unsigned
if (bInt < 0) bInt = -9223372036854775808LL - bInt;
^
iae.cpp:8:13: error: use of undeclared identifier 'std'
return (std::abs(aInt - bInt) <= 10000);
^
2 warnings and 1 error generated.
ERROR root: compiler frontend failed to generate LLVM bitcode, halting
如何摆脱这些警告和错误,甚至可以使用emscripten编译IsAlmostEqual()
?
答案 0 :(得分:1)
似乎和你一样
<cstdlib>