You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removes unreferenced functions or data that are COMDATs or only have internal linkage. When**/Zc:inline** is specified, the compiler requires that translation units that use inline data or inline functions must also include the definitions for the data or functions.
10
+
Removes unreferenced data or functions that are COMDATs, or that only have internal linkage. Under**/Zc:inline**, the compiler specifies that translation units with inline data or functions must also include their definitions.
11
11
12
12
## Syntax
13
13
14
14
> **/Zc:inline**[**-**]
15
15
16
16
## Remarks
17
17
18
-
When **/Zc:inline** is specified, the compiler does not emit symbol information for unreferenced COMDAT functions or data, or for functions or data that have internal linkage only. This optimization simplifies some of the work performed by the linker in release builds or when the linker option[/OPT:REF](opt-optimizations.md)is specified. When the compiler performs this optimization, it can significantly reduce .obj file size and improve linker speeds. This compiler option is not enabled when optimizations are disabled ([/Od](od-disable-debug.md)) or when [/GL (Whole Program Optimization)](gl-whole-program-optimization.md) is specified.
18
+
When **/Zc:inline** is specified, the compiler doesn't emit symbol information for unreferenced COMDAT functions or data. Or, for data or functions that have internal linkage only. This optimization simplifies some of the work the linker does in release builds, or when you specify the[/OPT:REF](opt-optimizations.md)linker option. This compiler optimizationcan significantly reduce .obj file size and improve linker speeds. The compiler option isn't enabled when you disable optimizations ([/Od](od-disable-debug.md)). Or, when you specify [/GL (Whole Program Optimization)](gl-whole-program-optimization.md).
19
19
20
-
By default, this option is off (**/Zc:inline-**) in command-line builds. The [/permissive-](permissive-standards-conformance.md) option does not enable **/Zc:inline**. In MSBuild projects, the option is set by the **Configuration Properties** > **C/C++** > **Language** > **Remove unreferenced code and data** property, which is set to **Yes** by default.
20
+
By default, this option is off (**/Zc:inline-**) in command-line builds. The [/permissive-](permissive-standards-conformance.md) option doesn't enable **/Zc:inline**. In MSBuild projects, the option is set by the **Configuration Properties** > **C/C++** > **Language** > **Remove unreferenced code and data** property, which is set to **Yes** by default.
21
21
22
22
If **/Zc:inline** is specified, the compiler enforces the C++11 requirement that all functions declared `inline` must have a definition available in the same translation unit if they are used. When the option is not specified, the Microsoft compiler allows non-conformant code that invokes functions declared `inline` even if no definition is visible. For more information, see the C++11 standard, in section 3.2 and section 7.1.2. This compiler option was introduced in Visual Studio 2013 Update 2.
23
23
@@ -59,7 +59,7 @@ void Example::normal_call() {
59
59
// Compile by using: cl /W4 /EHsc /O2 zcinline.cpp example.cpp
60
60
#include"example.h"
61
61
62
-
voidmain() {
62
+
intmain() {
63
63
Example example;
64
64
example.inline_call(); // normal call when definition unavailable
When the **/Zc:referenceBinding** option is specified, the compiler does not allow a non-const lvalue reference to bind to a temporary.
10
+
When the **/Zc:referenceBinding** option is specified, the compiler doesn't allow a non-const lvalue reference to bind to a temporary.
11
11
12
12
## Syntax
13
13
14
14
> **/Zc:referenceBinding**[**-**]
15
15
16
16
## Remarks
17
17
18
-
If **/Zc:referenceBinding** is specified, the compiler follows section 8.5.3 of the C++11 standard and does not allow expressions that bind a user-defined type temporary to a non-const lvalue reference. By default, or if **/Zc:referenceBinding-** is specified, the compiler allows such expressions as a Microsoft extension, but a level 4 warning is issued. For code security, portability and conformance, we recommend that you use **/Zc:referenceBinding**.
18
+
If **/Zc:referenceBinding** is specified, the compiler follows section 8.5.3 of the C++11 standard: It doesn't allow expressions that bind a user-defined type temporary to a non-const lvalue reference. By default, or if **/Zc:referenceBinding-** is specified, the compiler allows such expressions as a Microsoft extension, but a level 4 warning is issued. For code security, portability and conformance, we recommend you use **/Zc:referenceBinding**.
19
19
20
20
The **/Zc:referenceBinding** option is off by default. The [/permissive-](permissive-standards-conformance.md) compiler option implicitly sets this option, but it can be overridden by using **/Zc:referenceBinding-**.
21
21
@@ -35,7 +35,7 @@ S g() {
35
35
return S{};
36
36
}
37
37
38
-
void main() {
38
+
int main() {
39
39
S& s = g(); // warning C4239 at /W4
40
40
const S& cs = g(); // okay, bound to const ref
41
41
f(g()); // Extension: error C2664 only if /Zc:referenceBinding
Copy file name to clipboardExpand all lines: docs/cpp/attributes.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ Attributes represent a standardized alternative to vendor-specific extensions su
57
57
- `[[gsl::suppress(rules)]]` This Microsoft-specific attribute is used for suppressing warnings from checkers that enforce [Guidelines Support Library (GSL)](https://github.com/Microsoft/GSL) rules in code. For example, consider this code snippet:
58
58
59
59
```cpp
60
-
void main()
60
+
int main()
61
61
{
62
62
int arr[10]; // GSL warning 26494 will be fired
63
63
int* p = arr; // GSL warning 26485 will be fired
@@ -77,4 +77,5 @@ Attributes represent a standardized alternative to vendor-specific extensions su
77
77
78
78
- 26481 (Bounds Rule 1: Don't use pointer arithmetic. Use span instead.)
79
79
80
-
The first two warnings fire when you compile this code with the CppCoreCheck code analysis tool installed and activated. But the third warning doesn't fire because of the attribute. You can suppress the entire bounds profile by writing [[gsl::suppress(bounds)]] without including a specific rule number. The C++ Core Guidelines are designed to help you write better and safer code. The suppress attribute makes it easy to turn off the warnings when they are not wanted.
80
+
The first two warnings fire when you compile this code with the CppCoreCheck code analysis tool installed and activated. But the third warning doesn't fire because of the attribute. You can suppress the entire bounds profile by writing [[gsl::suppress(bounds)]] without including a specific rule number. The C++ Core Guidelines are designed to help you write better and safer code. The suppress attribute makes it easy to turn off the warnings when they are not wanted.
0 commit comments