Skip to content

Commit 5e932a0

Browse files
authored
Merge pull request MicrosoftDocs#825 from MicrosoftDocs/master
5/21 AM Publish
2 parents 06b1f7b + 2f61867 commit 5e932a0

File tree

7 files changed

+1227
-131
lines changed

7 files changed

+1227
-131
lines changed

docs/build/reference/TOC.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#### [/favor (Optimize for Architecture Specifics)](favor-optimize-for-architecture-specifics.md)
5454
#### [/FC (Full Path of Source Code File in Diagnostics)](fc-full-path-of-source-code-file-in-diagnostics.md)
5555
#### [/fp (Specify Floating-Point Behavior)](fp-specify-floating-point-behavior.md)
56+
##### [Microsoft Visual C++ floating point optimization](floating-point-optimization.md)
5657
#### [/FS (Force Synchronous PDB Writes)](fs-force-synchronous-pdb-writes.md)
5758
#### [/GA (Optimize for Windows Application)](ga-optimize-for-windows-application.md)
5859
#### [/Gd, /Gr, /Gv, /Gz (Calling Convention)](gd-gr-gv-gz-calling-convention.md)

docs/build/reference/floating-point-optimization.md

Lines changed: 1093 additions & 0 deletions
Large diffs are not rendered by default.

docs/build/reference/fp-specify-floating-point-behavior.md

Lines changed: 88 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -13,89 +13,91 @@ ms.author: "corob"
1313
ms.workload: ["cplusplus"]
1414
---
1515
# /fp (Specify Floating-Point Behavior)
16-
Specifies floating-point behavior in a source code file.
17-
18-
## Syntax
19-
20-
```
21-
/fp:[precise | except[-] | fast | strict ]
22-
```
23-
24-
## Flags
25-
**precise**
26-
The default.
27-
28-
Improves the consistency of floating-point tests for equality and inequality by disabling optimizations that could change the precision of floating-point calculations. (Maintaining specific precision is required for strict ANSI conformance.) By default, in code for x86 architectures the compiler uses the coprocessor's 80-bit registers to hold the intermediate results of floating-point calculations. This increases program speed and decreases program size. However, because the calculation involves floating-point data types that are represented in memory by less than 80 bits, carrying the extra bits of precision—80 bits minus the number of bits in a smaller floating-point type—through a lengthy calculation can produce inconsistent results.
29-
30-
With **/fp:precise** on x86 processors, the compiler performs rounding on variables of type `float` to the correct precision for assignments and casts and when parameters are passed to a function. This rounding guarantees that the data does not retain any significance greater than the capacity of its type. A program compiled with **/fp:precise** can be slower and larger than one compiled without **/fp:precise**. **/fp:precise** disables intrinsics; the standard run-time library routines are used instead. For more information, see [/Oi (Generate Intrinsic Functions)](../../build/reference/oi-generate-intrinsic-functions.md).
31-
32-
The following floating-point behavior is enabled with **/fp:precise**:
33-
34-
- Contractions—that is, using a composite operation that has just one rounding at the end to replace multiple operations.
35-
36-
- Expression optimizations that are invalid for special values (NaN, +infinity, -infinity, +0, -0) are not allowed. The optimizations x-x => 0, x*0 => 0, x-0 => x, x+0 => x, and 0-x => -x are invalid for various reasons. (See IEEE 754 and the C99 standard.)
37-
38-
- The compiler correctly handles comparisons that involve NaN. For example, x != x evaluates to **true** if `x` is NaN and ordered comparisons involving NaN raise an exception.
39-
40-
- Expression evaluation follows the C99 FLT_EVAL_METHOD=2, with this exception: When you program for x86 processors, because the FPU is set to 53-bit precision, this is considered long-double precision.
41-
42-
- Multiplication by exactly 1.0 transformed into a use of the other factor. x*y\*1.0 is transformed into x\*y. Similarly, x\*1.0\*y is transformed into x\*y.
43-
44-
- Division by exactly 1.0 is transformed into a use of the dividend. x*y/1.0 is transformed into x\*y. Similarly, x/1.0\*y is transformed into x\*y.
45-
46-
Using **/fp:precise** when [fenv_access](../../preprocessor/fenv-access.md) is ON disables optimizations such as compile-time evaluations of floating-point expressions. For example, if you use [_control87, _controlfp, \__control87_2](../../c-runtime-library/reference/control87-controlfp-control87-2.md) to change the rounding mode, and the compiler performs a floating-point calculation, the rounding mode you specified is not in effect unless `fenv_access` is ON.
47-
48-
**/fp:precise** replaces the **/Op** compiler option.
49-
50-
**fast**
51-
Creates the fastest code in most cases by relaxing the rules for optimizing floating-point operations. This enables the compiler to optimize floating-point code for speed at the expense of accuracy and correctness. When **/fp:fast** is specified, the compiler may not round correctly at assignment statements, typecasts, or function calls, and may not perform rounding of intermediate expressions. The compiler may reorder operations or perform algebraic transforms—for example, by following associative and distributive rules—without regard to the effect on finite precision results. The compiler may change operations and operands to single-precision instead of following the C++ type promotion rules. Floating-point-specific contraction optimizations are always enabled ([fp_contract](../../preprocessor/fp-contract.md) is ON). Floating-point exceptions and FPU environment access are disabled (**/fp:except-** is implied and [fenv_access](../../preprocessor/fenv-access.md) is OFF).
52-
53-
**/fp:fast** cannot be used with **/fp:strict** or **/fp:precise**. The last option specified on the command line is used. Specifying both **/fp:fast** and **/fp:except** generates a compiler error.
54-
55-
Specifying [/Za, /Ze (Disable Language Extensions)](../../build/reference/za-ze-disable-language-extensions.md) (ANSI compatibility) and **/fp:fast** may cause unexpected behavior. For example, single-precision floating-point operations may not be rounded to single precision.
56-
57-
**except[-]**
58-
Reliable floating-point exception model. Exceptions are raised immediately after they are triggered. By default, this option is off. Appending a minus sign to the option explicitly disables it.
59-
60-
**strict**
61-
The strictest floating-point model. **/fp:strict** causes [fp_contract](../../preprocessor/fp-contract.md) to be OFF and [fenv_access](../../preprocessor/fenv-access.md) to be ON. **/fp:except** is implied and can be disabled by explicitly specifying **/fp:except-**. When used with **/fp:except-**, **/fp:strict** enforces strict floating-point semantics but without respect for exceptional events.
62-
63-
## Remarks
64-
Multiple **/fp** options can be specified in the same compilation.
65-
66-
To control floating-point behavior by function, see the [float_control](../../preprocessor/float-control.md) pragma. This overrides the **/fp** compiler setting. We recommend you save and restore local floating-point behavior as good engineering practice:
67-
68-
```cpp
69-
#pragma float_control(precise, on, push)
70-
// Code that uses /fp:precise mode
71-
#pragma float_control(pop)
72-
```
73-
74-
Most of the floating-point optimizations related to **/fp:strict**, **/fp:except** (and its corresponding pragmas), and the `fp_contract` pragma are machine-dependent. **/fp:strict** and **/fp:except** are not compatible with **/clr**.
75-
76-
**/fp:precise** should address most of an application's floating-point requirements. You can use **/fp:except** and **/fp:strict**, but there may be some decrease in performance. If performance is most important, consider whether to use **/fp:fast**.
77-
78-
**/fp:strict**, **/fp:fast**, and **/fp:precise** are precision (correctness) modes. Only one can be in effect at a time. If both **/fp:strict** and **/fp:precise** are specified, the compiler uses the one that it processes last. Both **/fp:strict** and **/fp:fast** cannot be specified.
79-
80-
For more information, see [Microsoft Visual C++ Floating-Point Optimization](http://msdn.microsoft.com/library/aa289157.aspx).
81-
82-
### To set this compiler option in the Visual Studio development environment
83-
84-
1. Open the project's **Property Pages** dialog box. For details, see [Working with Project Properties](../../ide/working-with-project-properties.md).
85-
86-
2. Expand the **Configuration Properties** node.
87-
88-
3. Expand the **C/C++** node.
89-
90-
4. Select the **Code Generation** property page.
91-
92-
5. Modify the **Floating Point Model** property.
93-
94-
### To set this compiler option programmatically
95-
96-
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.floatingPointModel%2A>.
97-
98-
## See Also
99-
[Compiler Options](../../build/reference/compiler-options.md)
100-
[Setting Compiler Options](../../build/reference/setting-compiler-options.md)
101-
[Microsoft Visual C++ Floating Point Optimization](http://msdn.microsoft.com/library/aa289157.aspx)
16+
17+
Specifies floating-point behavior in a source code file.
18+
19+
## Syntax
20+
21+
> **/fp:**[**precise** | **except**[**-**] | **fast** | **strict**]
22+
23+
### Arguments
24+
25+
#### precise
26+
27+
The default value of **/fp** is **/fp:precise**.
28+
29+
The **/fp:precise** flag improves the consistency of floating-point tests for equality and inequality by disabling optimizations that could change the precision of floating-point calculations. (Maintaining specific precision is required for strict ANSI conformance.) By default, in code for x86 architectures that use x87 coprocessor instructions, the compiler uses the coprocessor's 80-bit registers to hold the intermediate results of floating-point calculations. This increases program speed and decreases program size. However, because the calculation involves floating-point data types that are represented in memory by less than 80 bits, carrying the extra bits of precision—80 bits minus the number of bits in a smaller floating-point type—through a lengthy calculation can produce inconsistent results.
30+
31+
With **/fp:precise** on x86 processors, the compiler performs rounding on variables of type `float` to the correct precision for assignments and casts and when parameters are passed to a function. This rounding guarantees that the data does not retain any significance greater than the capacity of its type. A program compiled with **/fp:precise** can be slower and larger than one compiled without **/fp:precise**. **/fp:precise** disables intrinsics; the standard run-time library routines are used instead. For more information, see [/Oi (Generate Intrinsic Functions)](../../build/reference/oi-generate-intrinsic-functions.md).
32+
33+
The following floating-point behavior is enabled with **/fp:precise**:
34+
35+
- Contractions—that is, using a composite operation that has just one rounding at the end to replace multiple operations.
36+
37+
- Expression optimizations that are invalid for special values (NaN, +infinity, -infinity, +0, -0) are not allowed. The optimizations x-x => 0, x*0 => 0, x-0 => x, x+0 => x, and 0-x => -x are invalid for various reasons. (See IEEE 754 and the C99 standard.)
38+
39+
- The compiler correctly handles comparisons that involve NaN. For example, x != x evaluates to **true** if `x` is NaN and ordered comparisons involving NaN raise an exception.
40+
41+
- Expression evaluation follows the C99 FLT_EVAL_METHOD=2, with this exception: When you program for x86 processors, because the FPU is set to 53-bit precision, this is considered long-double precision.
42+
43+
- Multiplication by exactly 1.0 transformed into a use of the other factor. x*y\*1.0 is transformed into x\*y. Similarly, x\*1.0\*y is transformed into x\*y.
44+
45+
- Division by exactly 1.0 is transformed into a use of the dividend. x*y/1.0 is transformed into x\*y. Similarly, x/1.0\*y is transformed into x\*y.
46+
47+
Using **/fp:precise** when [fenv_access](../../preprocessor/fenv-access.md) is ON disables optimizations such as compile-time evaluations of floating-point expressions. For example, if you use [_control87, _controlfp, \__control87_2](../../c-runtime-library/reference/control87-controlfp-control87-2.md) to change the rounding mode, and the compiler performs a floating-point calculation, the rounding mode you specified is not in effect unless `fenv_access` is ON.
48+
49+
**/fp:precise** replaces the **/Op** compiler option.
50+
51+
#### fast
52+
53+
The **/fp:fast** option creates the fastest code in most cases by relaxing the rules for optimizing floating-point operations. This enables the compiler to optimize floating-point code for speed at the expense of accuracy and correctness. When **/fp:fast** is specified, the compiler may not round correctly at assignment statements, typecasts, or function calls, and may not perform rounding of intermediate expressions. The compiler may reorder operations or perform algebraic transforms—for example, by following associative and distributive rules—without regard to the effect on finite precision results. The compiler may change operations and operands to single-precision instead of following the C++ type promotion rules. Floating-point-specific contraction optimizations are always enabled ([fp_contract](../../preprocessor/fp-contract.md) is ON). Floating-point exceptions and FPU environment access are disabled (**/fp:except-** is implied and [fenv_access](../../preprocessor/fenv-access.md) is OFF).
54+
55+
**/fp:fast** cannot be used with **/fp:strict** or **/fp:precise**. The last option specified on the command line is used. Specifying both **/fp:fast** and **/fp:except** generates a compiler error.
56+
57+
Specifying [/Za, /Ze (Disable Language Extensions)](../../build/reference/za-ze-disable-language-extensions.md) (ANSI compatibility) and **/fp:fast** may cause unexpected behavior. For example, single-precision floating-point operations may not be rounded to single precision.
58+
59+
#### except
60+
61+
The **/fp:except** option enables a reliable floating-point exception model. Exceptions are raised immediately after they are triggered. By default, this option is off. Appending a minus sign to the option (**/fp:except-**) explicitly disables it.
62+
63+
#### strict
64+
65+
The **/fp:strict** option enables the strictest floating-point model. **/fp:strict** causes [fp_contract](../../preprocessor/fp-contract.md) to be OFF and [fenv_access](../../preprocessor/fenv-access.md) to be ON. **/fp:except** is implied and can be disabled by explicitly specifying **/fp:except-**. When used with **/fp:except-**, **/fp:strict** enforces strict floating-point semantics but without respect for exceptional events.
66+
67+
## Remarks
68+
69+
Multiple **/fp** options can be specified in the same compilation.
70+
71+
To control floating-point behavior by function, see the [float_control](../../preprocessor/float-control.md) pragma. This overrides the **/fp** compiler setting. We recommend you save and restore local floating-point behavior as good engineering practice:
72+
73+
```cpp
74+
#pragma float_control(precise, on, push)
75+
// Code that uses /fp:precise mode
76+
#pragma float_control(pop)
77+
```
78+
79+
Most of the floating-point optimizations related to **/fp:strict**, **/fp:except** (and its corresponding pragmas), and the `fp_contract` pragma are machine-dependent. **/fp:strict** and **/fp:except** are not compatible with **/clr**.
80+
81+
**/fp:precise** should address most of an application's floating-point requirements. You can use **/fp:except** and **/fp:strict**, but there may be some decrease in performance. If performance is most important, consider whether to use **/fp:fast**.
82+
83+
**/fp:strict**, **/fp:fast**, and **/fp:precise** are precision (correctness) modes. Only one can be in effect at a time. If both **/fp:strict** and **/fp:precise** are specified, the compiler uses the one that it processes last. Both **/fp:strict** and **/fp:fast** cannot be specified.
84+
85+
For more information, see [Microsoft Visual C++ Floating-Point Optimization](floating-point-optimization.md).
86+
87+
### To set this compiler option in the Visual Studio development environment
88+
89+
1. Open the project's **Property Pages** dialog box. For details, see [Working with Project Properties](../../ide/working-with-project-properties.md).
90+
91+
1. Expand the **Configuration Properties** > **C/C++** > **Code Generation** property page.
92+
93+
1. Modify the **Floating Point Model** property.
94+
95+
### To set this compiler option programmatically
96+
97+
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.floatingPointModel%2A>.
98+
99+
## See also
100+
101+
- [Compiler Options](compiler-options.md)
102+
- [Setting Compiler Options](setting-compiler-options.md)
103+
- [Microsoft Visual C++ Floating Point Optimization](floating-point-optimization.md)

docs/linux/cmake-linux-project.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
---
22
title: "Configure a Linux CMake project in Visual Studio | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "10/25/2107"
4+
ms.date: "04/28/2018"
5+
ms.reviewer: ""
6+
ms.suite: ""
57
ms.technology: ["cpp-linux"]
68
ms.tgt_pltfrm: "Linux"
79
ms.topic: "conceptual"
@@ -38,7 +40,8 @@ int main(int argc, char* argv[])
3840
}
3941
```
4042
41-
CMakeLists.txt:
43+
CMakeLists.txt:
44+
4245
```cmd
4346
project (hello-cmake)
4447
add_executable(hello-cmake hello.cpp)
@@ -53,6 +56,9 @@ After you specify a Linux target, your source is copied to your Linux machine. T
5356

5457
![Generate CMake cache on Linux](media/cmake-linux-1.png "Generate the CMake cache on Linux")
5558

59+
**Visual Studio 2017 version 15.7 and later:**
60+
To provide IntelliSense support for remote headers, Visual Studio automatically copies them to a directory on your local Windows machine. For more information, see [IntelliSense for remote headers](configure-a-linux-project.md#remote_intellisense).
61+
5662
## Debug the project
5763
To debug your code on the remote system, set a breakpoint, select the CMake target as the startup item in the toolbar menu next to the project setting, and click run (or press F5).
5864

@@ -78,6 +84,7 @@ To change the default CMake settings, choose **CMake | Change CMake Settings | C
7884
"inheritEnvironments": [ "linux-x64" ]
7985
}
8086
```
87+
8188
The `name` value can be whatever you like. The `remoteMachineName` value specifies which remote system to target, in case you have more than one. IntelliSense is enabled for this field to help you select the right system. The field `remoteCMakeListsRoot` specifies where your project sources will be copied to on the remote system. The field `remoteBuildRoot` is where the build output will be generated on your remote system. That output is also copied locally to the location specified by `buildRoot`.
8289

8390
## Building a supported CMake release from source

0 commit comments

Comments
 (0)