次の方法で共有


/Gf, /GF   (Eliminate Duplicate Strings)

OverviewHow Do ICompiler Options

This option enables the compiler to place a single copy of identical strings into the .EXE file. Because identical strings are copied into a single memory location, programs compiled with this option can be smaller than those compiled without it. This space optimization is also called “string pooling.” Using this option ensures that string pooling occurs in most cases.

Command Line Project Settings Description
/Gf Eliminate Duplicate Strings Pools strings
/GF Not applicable Pools strings and places them in read-only memory

To find the Eliminate Duplicate Strings option in the development environment, click Settings on the Project menu. Then click the C/C++ tab, and click Customize in the Category box.

The /GF option enables the compiler to pool strings and place them in read-only memory. By placing the strings in read-only memory, the operating system does not need to swap that portion of memory. Instead, it can read the strings back from the image file. Strings placed in read-only memory cannot be modified; if you try to modify them, you will see an Application Error dialog box.

The /GF option is comparable to the /Gf option, except that /Gf does not place the strings in read-only memory. When you are using the /Gf option, your program must not write over pooled strings. Also, if you use identical strings to allocate string buffers, the /Gf option pools the strings. Thus, what was intended as multiple pointers to multiple buffers ends up as multiple pointers to a single buffer. For example, with /Gf, the following code causes s and t to point to the same memory because they are initialized with the same string:

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