473,395 Members | 1,774 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.

Strange compile errors when merely including <map>

I recognize that I may not be giving sufficient information with this,
but in the interest of not bogging the list down with too much code,
I'll try and post just a little information and then if that is
insufficient I can post more.

I have a C++ project that compiles fine with no warnings or errors.
It is relying on STL classes where appropriate. In one of my classes,
I needed to create a static member variable that was an STL map. By
merely adding the line #include <map>, I suddenly get a whole slew of
compile errors, all of which appear to be in the standard include
files, such as:

[carl@e236014 initcard]$ make
g++ -O2 -ansi -pedantic -Wall -c -o cryptokiclass.o cryptokiclass.cc
g++ -O2 -ansi -pedantic -Wall -c -o listener.o listener.cc
g++ -O2 -ansi -pedantic -Wall -c -o main.o main.cc
g++ -O2 -ansi -pedantic -Wall -c -o slot.o slot.cc
In file included from /usr/include/c++/3.3.3/string:53,
from /usr/include/c++/3.3.3/stdexcept:45,
from cryptokiclass.h:5,
from slot.h:7,
from slot.cc:1:
/usr/include/c++/3.3.3/bits/basic_string.h: In member function `int
std::basic_string<_CharT, _Traits, _Alloc>::compare(const
std::basic_string<_CharT, _Traits, _Alloc>&) const':
/usr/include/c++/3.3.3/bits/basic_string.h:830: error: syntax error
before `;'
token

.... etc. etc.

If I remove the #include <map> line, they all go away. Any ideas as
to what I can do to fix this?

Thank you very much for your time.

Carl Youngblood
Jul 22 '05 #1
3 1399
On 12 Jul 2004 11:40:19 -0700, Carl Youngblood <ca*************@gmail.com>
wrote:
I recognize that I may not be giving sufficient information with this,
but in the interest of not bogging the list down with too much code,
I'll try and post just a little information and then if that is
insufficient I can post more.

I have a C++ project that compiles fine with no warnings or errors.
It is relying on STL classes where appropriate. In one of my classes,
I needed to create a static member variable that was an STL map. By
merely adding the line #include <map>, I suddenly get a whole slew of
compile errors, all of which appear to be in the standard include
files, such as:

[carl@e236014 initcard]$ make
g++ -O2 -ansi -pedantic -Wall -c -o cryptokiclass.o cryptokiclass.cc
g++ -O2 -ansi -pedantic -Wall -c -o listener.o listener.cc
g++ -O2 -ansi -pedantic -Wall -c -o main.o main.cc
g++ -O2 -ansi -pedantic -Wall -c -o slot.o slot.cc
In file included from /usr/include/c++/3.3.3/string:53,
from /usr/include/c++/3.3.3/stdexcept:45,
from cryptokiclass.h:5,
from slot.h:7,
from slot.cc:1:
/usr/include/c++/3.3.3/bits/basic_string.h: In member function `int
std::basic_string<_CharT, _Traits, _Alloc>::compare(const
std::basic_string<_CharT, _Traits, _Alloc>&) const':
/usr/include/c++/3.3.3/bits/basic_string.h:830: error: syntax error
before `;'
token

... etc. etc.

If I remove the #include <map> line, they all go away. Any ideas as
to what I can do to fix this?

Thank you very much for your time.

Carl Youngblood


I would look to a macro that conflicts with one of the identifiers used in
the header file. Have a look at the line 830 in
/usr/include/c++/3.3.3/bits/basic_string.h and see if you can figure out
what it is. But if your line 830 is the same as my line 830 I would bet my
house on it being a macro by the name of 'min'.

john
Jul 22 '05 #2
You probably won't believe this, but after cutting my code into pieces
trying to figure out what was wrong, I was able to fix this error by
copying and pasting the code from the two offending files to a temporary
location, deleting the files and creating identical new copies. After
that everything compiled and ran fine. And I spent half a day banging
my head against the wall on this one! Thanks for your help.

Carl

John Harrison wrote:
I would look to a macro that conflicts with one of the identifiers used
in the header file. Have a look at the line 830 in
/usr/include/c++/3.3.3/bits/basic_string.h and see if you can figure
out what it is. But if your line 830 is the same as my line 830 I would
bet my house on it being a macro by the name of 'min'.

john

Jul 22 '05 #3
Carl Youngblood wrote:
You probably won't believe this, but after cutting my code into pieces
trying to figure out what was wrong, I was able to fix this error by
copying and pasting the code from the two offending files to a temporary
location, deleting the files and creating identical new copies. After
that everything compiled and ran fine. And I spent half a day banging
my head against the wall on this one! [...]


It's called "bit decay".
Jul 22 '05 #4

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

Similar topics

11
by: Markus Hämmerli | last post by:
I have seen in the STL that the map is working with one key. Does everyboby know if there is a possibility to have two key. Do you have a little example. Thanks Markus
8
by: Pierre Couderc | last post by:
I am looking for a "special" kind of map : - it is read like a map - if the searched element exists, it is given back imediately - if the searched element does not exist, an initialise() is...
14
by: laurence | last post by:
I am implementing a comprehensive image-map generator utility, so have been studying W3C HTML 4.01 Specification (http://www.w3.org/TR/html4/struct/objects.html#h-13.6) on image maps (among other...
3
by: Evgeny | last post by:
Hi, all! I didn't find yet solution for this problem! Somebody knows where is a catch? Looks like "operator =" or copy constructor not implemented in one of internal templates.... Thanks in...
11
by: Steve Edwards | last post by:
Hi, After making an iterator to a map and stepping through a loop, I want to delete any entries that satisfy a test from an external function. MyMapType::const_iterator iter; for(iter =...
13
by: Steve Edwards | last post by:
Hi, Given a map: typedef map<long, string, greater<long> > mapOfFreq; Is there a quicker way to find the rank (i.e. index) of the elememt that has the long value of x? At the moment I'm...
6
by: helpneeded | last post by:
Hi I am a novice using the <maptag. I have a question. I would really appreciate if you could answer me. I want to use the <maptag to dynamically update my map with coordinates. These...
1
by: Peter Lee | last post by:
store std::<map>::iterator is safe if didn't remove that element Is store std::<mapelement's pointer also safe ?
5
by: Mike Copeland | last post by:
I'm having difficulty updating map objects. In the code I've excerpted below, I store map objects without difficulty, but my attempts to modify elements of the stored data don't work. struct...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...

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.