473,614 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compilation Error of std::map in Win32 Console Project

The following program will result in a compile error when building under Debug but will compile under Release. Why does is work under Release mode but not under Debug

This program is developed under Visual Studio .NET 2003 in a Win32 Console Project

// VectorInsert.cp p : Defines the entry point for the console application
/

#include "stdafx.h
#include "VectorInse rt.h
#ifdef _DEBU
#define new DEBUG_NE
#endi

#include <vector
#include <string
#include <map

void addToVector(std ::vector<std::s tring>& out_Vector, std::string in_sValue)

// The one and only application objec

CWinApp theApp

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]

int nRetCode = 0

// initialize MFC and print and error on failur
if (!AfxWinInit(:: GetModuleHandle (NULL), NULL, ::GetCommandLin e(), 0)

// TODO: change error code to suit your need
_tprintf(_T("Fa tal Error: MFC initialization failed\n"))
return 1
std::vector<std ::string> loc_Vector1, loc_Vector2

std::map<std::s tring, std::map<std::s tring, std::vector<std ::string>>> loc_Map
addToVector(loc _Map["GENERIC"]["GENERIC"], "GENERIC")
std::vector<std ::string>::iter ator loc_Iter
loc_Vector2 = loc_Map["GENERIC"]["GENERIC"]
for (loc_Iter = loc_Vector2.beg in(); loc_Iter != loc_Vector2.end (); loc_Iter++)
std::cout << (*loc_Iter).c_s tr() << std::endl
return nRetCode
void addToVector(std ::vector<std::s tring>& out_Vector, std::string in_sValue)
std::vector<std ::string> loc_Vector1, loc_Vector2

loc_Vector1.pus h_back("Hello World")
loc_Vector1.pus h_back("How are you?")
loc_Vector1.pus h_back("Keep on smiling!")

loc_Vector2.pus h_back("Time to go")
loc_Vector2.pus h_back("Take care")
loc_Vector2.pus h_back("Goodbye World!")

loc_Vector1.ins ert(loc_Vector1 .end(), loc_Vector2.beg in(), loc_Vector2.end ())

std::vector<std ::string>::iter ator loc_Iter
for (loc_Iter = loc_Vector1.beg in(); loc_Iter != loc_Vector1.end (); loc_Iter++)
std::cout << (*loc_Iter).c_s tr() << std::endl
std::cout << std::endl << "End of addToVector()" << std::endl << std::endl
out_Vector = loc_Vector2

The error displayed is
Compiling..
VectorInsert.cp
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e\xtree(1133) : error C2061: syntax error : identifier '_Wherenode
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e\xtree(1130) : while compiling class-template member function 'std::_Tree<_Tr aits>::_Nodeptr std::_Tree<_Tra its>::_Buynode( std::_Tree<_Tra its>::_Nodeptr, std::_Tree<_Tra its>::_Nodeptr, std::_Tree<_Tra its>::_Nodeptr, const std::_Tree<_Tra its>::value_typ e &,char)
wit

_Traits=std::_T map_traits<std: :string,std::ma p<std::string,s td::vector<std: :string>>,std:: less<std::strin g>,std::allocat or<std::pair<co nst std::string,std ::map<std::stri ng,std::vector< std::string>>>> ,false

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\includ e\map(77) : see reference to class template instantiation 'std::_Tree<_Tr aits>' being compile
wit

_Traits=std::_T map_traits<std: :string,std::ma p<std::string,s td::vector<std: :string>>,std:: less<std::strin g>,std::allocat or<std::pair<co nst std::string,std ::map<std::stri ng,std::vector< std::string>>>> ,false

d:\TestVisualC+ +\J13 Tests\VectorIns ert\VectorInser t\VectorInsert. cpp(35) : see reference to class template instantiation 'std::map<_Kty, _Ty>' being compile
wit

_Kty=std::strin g
_Ty=std::map<st d::string,std:: vector<std::str ing>
Build log was saved at "file://d:\TestVisualC+ +\J13 Tests\VectorIns ert\VectorInser t\Debug\BuildLo g.htm
VectorInsert - 1 error(s), 0 warning(s)
Nov 17 '05 #1
1 6469
Avery Fong wrote:
The following program will result in a compile error when building under Debug but will compile under Release. Why does is work under Release mode but not under Debug?

This program is developed under Visual Studio .NET 2003 in a Win32 Console Project.

// VectorInsert.cp p : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "VectorInsert.h "
#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#include <vector>
#include <string>
#include <map>


The #define above is interfering with placement new as used by the STL
implementation. You can delete the #ifdef block, or you can try moving it
below all the #includes. Besides messing up placement new, the #define can
also mess up class-specific operator new. However, it does give you filename
and line number info of the allocation statements, for code which textually
follows the #define, and this can be useful when debugging some types of
heap errors. The #define is not necessary to use the debug heap; it merely
augments the tracking that is done in its absence with filename and line
number info for new-expressions which textually follow its definition.

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
30033
by: Woodster | last post by:
I have declared the following std::map<std::string, std::string> myMap; to pass myMap to functions should I be declaring functions as: void function(std::map<std::string, std::string>); or is there a preferred/better method of doing this?
1
1860
by: Antti Granqvist | last post by:
Hello! I have following object relations: Competition 1--* Category 1--* Course 1 | | * Course
44
8762
by: jmoy | last post by:
I am a C programmer graduating to C++. As an exercise I wrote a program to count the number of times that different words occur in a text file. Though a hash table might have been a better choice, I chose to use std::map. However, the program runs at less than half the speed of an equivalent program that uses ordinary handcoded binary trees. The result is not changed very much if I replace std::string as the key with a simple string class...
1
3546
by: Saeed Amrollahi | last post by:
Dear All C++ Programmers Hello I am Saeed Amrollahi. I am a software engineer in Tehran Sewerage Company. I try to use std::map and map::find member function. I use Visual Studio .NET. my program uses two MFC classes: CRect and CPoint which represents Rectangle and Point concepts (as usual) and a user
5
8734
by: Peter Jansson | last post by:
Hello, I have the following code: std::map<int,std::set<std::string> > k; k="1234567890"; k="2345678901"; //... std::set<std::string> myMethod(std::map<int,std::set<std::string> > k) throw(std::runtime_error)
1
3718
by: Maxwell | last post by:
Hello, I having having oodles of trouble using the std lib in my MC++ (VS.NET 2003) Class library. I figured out a simple sample to reproduce the errors I am having. Create a MC++ (VS.NET 2003) class library and type in the following code below: #include <map> #include<string>
7
19871
by: Torben Laursen | last post by:
Hi Can anyone tell me if there is a class in C# similar to the class std::map in C++? I need a way to map enum to double and was hoping to avoid using any "if" code Thanks Torben
4
6243
by: Evyn | last post by:
Hi all, I'm starting to fool around with STL and in particular std::map. How do I iterate through one map and insert every pair in another map? I have the following so far: map<double, doublefset1; map<double, doublefset3;
7
6252
by: DevNull | last post by:
Hi there everyone, I'm creating a very simple immediate mode command interpreter. The final purpose is to provide a pluggable control and command console for a MUD server I have written. The basic theory is we wrap the functions we want exposed to the console in a function with a prototype of int func(State*)
0
8130
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8576
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8275
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7091
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5538
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1423
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.