473,558 Members | 3,004 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 6460
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
30023
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
1856
by: Antti Granqvist | last post by:
Hello! I have following object relations: Competition 1--* Category 1--* Course 1 | | * Course
44
8722
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....
1
3542
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
8728
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
3712
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
19864
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
6239
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
6249
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
7550
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...
0
8061
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...
0
7915
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5455
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5172
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...
0
3579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2046
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
1165
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
872
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...

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.