fmax and fmin alternative in c89
当试图使用Visual Studio 2010编译GLFW时,出现错误,“Error LNK2019:无法解析的外部符号_fmax在Error 3 error LNK2019: unresolved external symbol _fmax referenced in function _star F:DevPROGSGLFWbuildtestscursor.obj cursor
引用Error 3 error LNK2019: unresolved external symbol _fmax referenced in function _star F:DevPROGSGLFWbuildtestscursor.obj cursor
但是,据我所知,Visual Studio不支持c99。那么什么是解决方法呢?
As you said, these functions were added in C99 and C++11. Microsoft's C compiler does not support C99, but later versions of the C++ compiler do support C++11. The one bundled with Visual Studio 2013 will have these functions. I'm not sure if they're usable when you're compiling C code or not.
If you're stuck on an older version of the compiler, like VS 2010, it's trivial to implement these functions yourself. Put them in an MSVC-compatibility header:
#ifdef _MSC_VER
#define INLINE __inline
INLINE double fmax(double left, double right)
{ return (left > right) ? left : right; }
INLINE double fmin(double left, double right)
{ return (left < right) ? left : right; }
#endif
链接地址: http://www.djcxy.com/p/65872.html
下一篇: 在c89中fmax和fmin的选择