/Gf, /GF (Eliminate Duplicate Strings)

These options enable 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/write.

/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.

If you use /Gf, it is your program's responsibility not to overwrite pooled strings.

Note In the next release of Visual C++, /Gf will be removed from the compiler. You should either remove /Gf from your projects or replace it with /GF. /Gf can cause unexpected behavior if a string that was pooled with another one is written. So, you should not use /Gf if you write to your strings and if you are not writing to your strings, you should use /GF.

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: