NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

/Gf, /GF (Eliminate Duplicate Strings)

/Gf
/GF

These options enable the compiler to create a single copy of identical strings in the .exe file and in memory during execution, resulting in smaller programs—an optimization called “string pooling.”

/Gf pools strings.

/GF pools strings and places them in read-only memory.

If you use /GF to place pooled strings in read-only memory, the operating system does not swap that portion of memory and can read the strings back from the image file. You cannot modify strings in read-only memory. If you try to modify them, an Application Error results.

If you use /Gf, your program must not write over pooled strings.

If you use identical strings to allocate string buffers, the /Gf option pools the strings. What were intended as multiple pointers to multiple buffers end up as multiple pointers to a single buffer. In the following code, s and t are initialized with the same string. Compiling the code with /Gf causes the 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. This means that strings will be pooled and placed in read-only memory even if you specify /Gf manually.

See Also

Compiler Options | Setting Compiler Options