Is there a -ffast-math flag equivalent for the Vis

2019-06-21 18:43发布

I'm working with the default C++ compiler (I guess it's called the "Visual Studio C++ compiler") that comes with Visual Studio 2013 with the flag /Ox (Full Optimization). Due to floating point side effects, I must disable the -ffast-math flag when using the gcc compiler. Is there an equivalent option for this flag in the configuration of the Visual Studio C++ compiler?

2条回答
祖国的老花朵
2楼-- · 2019-06-21 19:28

None of the MSVC++ options enable the optimizations which are invoked by g++ -ffast-math.

查看更多
Melony?
3楼-- · 2019-06-21 19:40

You are looking for /fp:precise, although that is also the default.

If you need the strictest floating point calculations that VS can offer, try /fp:strict, although that is probably overkill.

You probably have nothing to worry about since the default behavior should be what you desire. Just make sure that /fp:fast is not specified, but if you try to compile with both /fp:fast and /fp:precise you will get a compilation error anyway, so that should be easy to catch.

The link that Hans Passant provided to the MSDN website provides all the details you might want.

查看更多
登录 后发表回答