|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
/GF (Eliminate Duplicate Strings)
Enables the compiler to create a single copy of identical strings in the program image and in memory during execution, resulting in smaller programs, an optimization called string pooling.
/GF pools strings as read-only.
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. 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 as 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";
Theoption, used for Edit and Continue, automatically sets the /GF option.
/GF is in effect whenor /O2 is used.
To set this compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see.
Click the C/C++ folder.
Click the Code Generation property page.
Modify the Enable String Pooling property.
To set this compiler option programmatically