473,395 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.cpp : Defines the entry point for the console application
/

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

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

void addToVector(std::vector<std::string>& 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, ::GetCommandLine(), 0)

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

std::map<std::string, std::map<std::string, std::vector<std::string>>> loc_Map
addToVector(loc_Map["GENERIC"]["GENERIC"], "GENERIC")
std::vector<std::string>::iterator loc_Iter
loc_Vector2 = loc_Map["GENERIC"]["GENERIC"]
for (loc_Iter = loc_Vector2.begin(); loc_Iter != loc_Vector2.end(); loc_Iter++)
std::cout << (*loc_Iter).c_str() << std::endl
return nRetCode
void addToVector(std::vector<std::string>& out_Vector, std::string in_sValue)
std::vector<std::string> loc_Vector1, loc_Vector2

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

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

loc_Vector1.insert(loc_Vector1.end(), loc_Vector2.begin(), loc_Vector2.end())

std::vector<std::string>::iterator loc_Iter
for (loc_Iter = loc_Vector1.begin(); loc_Iter != loc_Vector1.end(); loc_Iter++)
std::cout << (*loc_Iter).c_str() << 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\include\xtree(1133) : error C2061: syntax error : identifier '_Wherenode
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xtree(1130) : while compiling class-template member function 'std::_Tree<_Traits>::_Nodeptr std::_Tree<_Traits>::_Buynode(std::_Tree<_Traits>: :_Nodeptr,std::_Tree<_Traits>::_Nodeptr,std::_Tree <_Traits>::_Nodeptr,const std::_Tree<_Traits>::value_type &,char)
wit

_Traits=std::_Tmap_traits<std::string,std::map<std ::string,std::vector<std::string>>,std::less<std:: string>,std::allocator<std::pair<const std::string,std::map<std::string,std::vector<std:: string>>>>,false

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

_Traits=std::_Tmap_traits<std::string,std::map<std ::string,std::vector<std::string>>,std::less<std:: string>,std::allocator<std::pair<const std::string,std::map<std::string,std::vector<std:: string>>>>,false

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

_Kty=std::string
_Ty=std::map<std::string,std::vector<std::string>
Build log was saved at "file://d:\TestVisualC++\J13 Tests\VectorInsert\VectorInsert\Debug\BuildLog.htm
VectorInsert - 1 error(s), 0 warning(s)
Nov 17 '05 #1
1 6449
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.cpp : 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
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>); ...
1
by: Antti Granqvist | last post by:
Hello! I have following object relations: Competition 1--* Category 1--* Course 1 | | * Course
44
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,...
1
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...
5
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)...
1
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)...
7
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
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,...
7
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...

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.