Skip to content

Latest commit

 

History

History
55 lines (36 loc) · 2.62 KB

gf-eliminate-duplicate-strings.md

File metadata and controls

55 lines (36 loc) · 2.62 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: /GF (Eliminate Duplicate Strings)
/GF (Eliminate Duplicate Strings)
11/04/2016
VC.Project.VCCLCompilerTool.StringPooling
VC.Project.VCCLWCECompilerTool.StringPooling
/gf
duplicate strings
Eliminate Duplicate Strings compiler option [C++]
pooling strings compiler option [C++]
-GF compiler option [C++]
/GF compiler option [C++]
GF compiler option [C++]
strings [C++], pooling
bb7b5d1c-8e1f-453b-9298-8fcebf37d16c

/GF (Eliminate Duplicate Strings)

Enables the compiler to create a single copy of identical strings in the program image and in memory during execution. This is an optimization called string pooling that can create smaller programs.

Syntax

/GF

Remarks

If you use /GF, the operating system does not swap the string portion of memory and can read the strings back from the image file.

/GF pools strings as read-only. If you try to modify strings under /GF, an application error occurs.

String pooling allows what were intended as multiple pointers to multiple buffers to be multiple pointers to a single buffer. In the following code, s and t are initialized with the same string. String pooling causes them to point to the same memory:

char *s = "This is a character buffer";
char *t = "This is a character buffer";

Note

The /ZI option, used for Edit and Continue, automatically sets the /GF option.

Note

The /GF compiler option creates an addressable section for each unique string. And by default, an object file can contain up to 65,536 addressable sections. If your program contains more than 65,536 strings, use the /bigobj compiler option to create more sections.

/GF is in effect when /O1 or /O2 is used.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.

  2. Select the Configuration Properties > C/C++ > Code Generation property page.

  3. Modify the Enable String Pooling property.

To set this compiler option programmatically

  • See xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.StringPooling%2A.

See also

MSVC Compiler Options
MSVC Compiler Command-Line Syntax