Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a -ffast-math flag equivalent for the Visual Studio C++ compiler

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?

like image 858
Matthias Avatar asked Oct 19 '14 11:10

Matthias


People also ask

Does Visual Studio have a compiler for C?

The Visual Studio build tools include a C compiler that you can use to create everything from basic console programs to full Windows Desktop applications, mobile apps, and more.

How do I add a compiler flag in Visual Studio?

In Visual StudioIn the left pane, select Configuration Properties, C/C++ and then choose the compiler option category. The topic for each compiler option describes how it can be set and where it is found in the development environment.

What are compiler flags in C?

Compiler flags are options you give to gcc when it compiles a file or set of files. You may provide these directly on the command line, or your development tools may generate them when they invoke gcc. This section describes just the flags that are specific to Objective-C.

Does Visual Studio Code have its own compiler?

No, it does not come with its own VS compiler, except for (apparently) "ASP.NET, Node. js, or TypeScript". But it is the first cross-platform development tool in the Visual Studio family, for a certain definition of the phrase "development tool".


1 Answers

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.

like image 159
pattivacek Avatar answered Sep 28 '22 16:09

pattivacek