You receive an "RC2151 Cannot re-use string constants" error message when you try to add a string resource to an application in Visual C++ (194299)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Editions 4.2b
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q194299 SYMPTOMS Adding a string resource to an application that uses MFC as
a static link library may result in the use of the same ID value twice in a
STRINGTABLE statement. The Resource Compiler generates the following
error: RC2151 Cannot re-use string constants
This problem is likely to happen when using the resource editor to
add the string. CAUSE When using MFC as a static library in an application, MFC's
resources are compiled into the .exe. The statement on line 26 of
Afxres.rc
#ifndef _AFXDLL
causes string resources defined in Afxres.h to be used in the
application when building Afxres.rc. If an ID value of another string resource
matches any of the ID values used in Afxres.rc, the same ID value is used twice
in a STRINGTABLE statement. NOTE: The problem is not multiple definitions of the ID symbol, but
rather, the use of the definition multiple times in a string table.
RESOLUTION Consult both Technical Note 20 "ID Naming and Numbering
Conventions" and the file Afxres.h to help locate ID values used by Windows or
MFC. Then remove any entries in the string table that use ID values more than
once (for example, an entry in the application's string table that has a ID
value matching an ID value in Afxres.h). STATUS This behavior is by design. REFERENCES For
more information, click the following article number to view the article in the
Microsoft Knowledge Base: 21569
RW2002 Error "Cannot Reuse String Constants" in RC.EXE
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by
Isaac Varon, Microsoft Corporation
Modification Type: | Major | Last Reviewed: | 6/2/2005 |
---|
Keywords: | kberrmsg kbtshoot kbprb kbResource kbString KB194299 kbAudDeveloper |
---|
|