Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

/H (Restrict Length of External Names)

/Hnumber

where:

number
Specifies the maximum length of external names allowed in a program.

Remarks

By default, the length of external (public) names is 2,047 characters. This is true for C and C++ programs. The /H option restricts the length of these names. Using /H can only decrease the maximum allowable length of identifiers, not increase it. A space between /H and number is optional.

If a program contains external names longer than number, the extra characters are ignored. If you compile a program without /H and if an identifier contains more than 2,047 characters, the compiler will generate C1064.

The limit on length includes any compiler-created leading underscore (_) or at sign (@). These characters are part of the identifier and take a significant location.

  • The compiler adds a leading underscore (_) to names modified by the __cdecl (default) and __stdcall calling conventions, and a leading at sign (@) to names modified by the __fastcall calling convention.
  • The compiler appends argument size information to names modified by the __fastcall and __stdcall calling conventions, and adds type information to C++ names.

You may find /H useful:

  • When you create mixed-language or portable programs.
  • When you use tools that impose limits on the length of external identifiers.
  • When you want to restrict the amount of space that symbols use in a debug build.

The following example shows how using /H can actually introduce errors if identifier lengths are limited too much:

/* When compiled with /H5, the following code will produce either
   *   error L2025: _func : symbol defined more than once
   *   -or-
   *   error LNK2005: _func already defined in '.obj file'
   *   fatal error LNK1169: one or more multiply defined symbols found
   */

   void func1(void);
   void func2(void);

   int main(void)
   {
      func1();
   }

   void func1(void)
   {
   }

   void func2(void)
   {
   }

You must also be careful when using the /H option because of predefined compiler identifiers. If the maximum identifier length is too small, certain predefined identifiers will be unresolved as well as certain library function calls. For example, if the printf function is used and the option /H5 is specified at compile time, the symbol _prin will be created in order to reference printf, and this will not be found in the library.

Use of /H is incompatible with /GL.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
  2. Click the C/C++ folder.
  3. Click the Command Line property page.
  4. Type the compiler option in the Additional Options box.

To set this compiler option programmatically

See AdditionalOptions.

See Also

Compiler Options | Setting Compiler Options

Show:
© 2014 Microsoft. All rights reserved.