BUG: You may receive compilation errors when you define the _CRTDBG_MAP_ALLOC constant and include the Stdlib.h file in a C++ application in Visual Studio 2005 (922317)
The information in this article applies to:
- Microsoft Visual Studio 2005 Team System Architect Edition
- Microsoft Visual Studio 2005 Team System Developer Edition
- Microsoft Visual Studio 2005 Team System Team Foundation:
- Microsoft Visual Studio 2005 Team System Test Edition
- Microsoft Visual Studio 2005 Express Edition
- Microsoft Visual Studio 2005 Standard Edition
- Microsoft Visual Studio 2005 Professional Edition
SYMPTOMSConsider the following scenario: - You create a C++ application in Microsoft Visual Studio 2005.
- You define the _CRTDBG_MAP_ALLOC constant.
- You include the following header files:
- You include the Crtdbg.h file before you include the Stdlib.h file.
For example, assume that the C++ application contains the following code. #define _CRTDBG_MAP_ALLOC
#include <malloc.h>
#include <crtdbg.h>
#include <stdlib.h> In this example, when you compile the C++ application, you receive the following compiler error messages: error C2059: syntax error : 'constant' error C2733: second C linkage of overloaded function '_dupenv_s_dbg' not allowed WORKAROUNDTo work around this problem, follow these steps: - Start Visual Studio 2005.
- On the File menu, point to Open, and then click Project/Solution.
- Locate the project or the solution that you want to open, and then click Open.
- Copy and paste the following code in the Code window. The code should be pasted immediately before the #include <stdlib.h> statement.
#pragma push_macro("_dupenv_s")
#pragma push_macro("_wdupenv_s")
#undef _dupenv_s
#undef _wdupenv_s - Copy and paste the following code in the Code window. The code should be pasted immediately after the #include <stdlib.h> statement.
#pragma pop_macro("_dupenv_s")
#pragma pop_macro("_wdupenv_s") - On the Build menu, click Build Solution.
The code should resemble the following code sample. #define _CRTDBG_MAP_ALLOC
#include <malloc.h>
#include <crtdbg.h>
#pragma push_macro("_dupenv_s")
#pragma push_macro("_wdupenv_s")
#undef _dupenv_s
#undef _wdupenv_s
#include <stdlib.h>
#pragma pop_macro("_dupenv_s")
#pragma pop_macro("_wdupenv_s") STATUS Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
Modification Type: | Major | Last Reviewed: | 7/21/2006 |
---|
Keywords: | kbcode kbtshoot kbbug KB922317 kbAudDeveloper |
---|
|