description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | |||
---|---|---|---|---|---|---|---|---|
Learn more about: /Gw (Optimize Global Data) |
/Gw (Optimize Global Data) |
11/04/2016 |
|
|
6f90f4e9-5eb8-4c47-886e-631278a5a4a9 |
Package global data in COMDAT sections for optimization.
/Gw[-]
The /Gw option causes the compiler to package global data in individual COMDAT sections. By default, /Gw is off and must be explicitly enabled. To explicitly disable it, use /Gw-. When both /Gw and /GL are enabled, the linker uses whole-program optimization to compare COMDAT sections across multiple object files in order to exclude unreferenced global data or to merge identical read-only global data. This can significantly reduce the size of the resulting binary executable.
When you compile and link separately, you can use the /OPT:REF linker option to exclude from the executable the unreferenced global data in object files compiled with the /Gw option.
You can also use the /OPT:ICF and /LTCG linker options together to merge in the executable any identical read-only global data across multiple object files compiled with the /Gw option.
For more information, see Introducing /Gw Compiler Switch on the C++ Team Blog.
-
Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.
-
Select the Configuration Properties > C/C++ > Command Line property page.
-
Modify the Additional Options property to include /Gw and then choose OK.
- See xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A.