User forums > General (but related to Code::Blocks)

map class

(1/4) > >>

jmccay:
The following code gives me 52 errors.  I am using mingw 3.4.5, and I got the same results with 3.4.4.  What am I missing?


--- Code: --- #include <map>
#include <string>
using namespace std;

typedef std::map<string,int> objPropsMap;

--- End code ---

errors:


--- Code: ---In file included from C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/map:66,
                 from ptl_interfaces.h:17,
                 from main.cpp:2:
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:157: error: `bidirectional_iterator_tag' does not name a type
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:228: error: `bidirectional_iterator_tag' does not name a type
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:325: error: `allocator' has not been declared
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:325: error: expected `>' before '<' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:325: error: expected unqualified-id before '>' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:703: error: expected `,' or `...' before '<' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:705: error: `bool ptl::std::operator==(int)' must have an argument of class or enumerated type
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:705: error: `bool ptl::std::operator==(int)' must take exactly two arguments
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: In function `bool ptl::std::operator==(int)':
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:706: error: `__x' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:706: error: `__y' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:707: error: `equal' is not a member of `ptl::std'
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: At global scope:
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:713: error: expected `,' or `...' before '<' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:715: error: `bool ptl::std::operator<(int)' must have an argument of class or enumerated type
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:715: error: `bool ptl::std::operator<(int)' must take exactly two arguments
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: In function `bool ptl::std::operator<(int)':
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:716: error: `lexicographical_compare' is not a member of `ptl::std'
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:716: error: `__x' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:717: error: `__y' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: At global scope:
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:723: error: expected `,' or `...' before '<' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:725: error: `bool ptl::std::operator!=(int)' must have an argument of class or enumerated type
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:725: error: `bool ptl::std::operator!=(int)' must take exactly two arguments
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: In function `bool ptl::std::operator!=(int)':
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:725: error: `__x' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:725: error: `__y' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: At global scope:
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:730: error: expected `,' or `...' before '<' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:732: error: `bool ptl::std::operator>(int)' must have an argument of class or enumerated type
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:732: error: `bool ptl::std::operator>(int)' must take exactly two arguments
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: In function `bool ptl::std::operator>(int)':
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:732: error: `__y' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:732: error: `__x' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: At global scope:
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:737: error: expected `,' or `...' before '<' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:739: error: `bool ptl::std::operator<=(int)' must have an argument of class or enumerated type
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:739: error: `bool ptl::std::operator<=(int)' must take exactly two arguments
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: In function `bool ptl::std::operator<=(int)':
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:739: error: `__y' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:739: error: `__x' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: At global scope:
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:744: error: expected `,' or `...' before '<' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:746: error: `bool ptl::std::operator>=(int)' must have an argument of class or enumerated type
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:746: error: `bool ptl::std::operator>=(int)' must take exactly two arguments
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: In function `bool ptl::std::operator>=(int)':
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:746: error: `__x' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:746: error: `__y' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h: At global scope:
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:751: error: variable or field `swap' declared void
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:751: error: `ptl::std::swap' declared as an `inline' variable
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:751: error: template declaration of `int ptl::std::swap'
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:751: error: `_Rb_tree' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:751: error: expected primary-expression before ',' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:751: error: expected primary-expression before ',' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:751: error: expected primary-expression before ',' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:751: error: expected primary-expression before ',' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:751: error: expected primary-expression before '>' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:751: error: `__x' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:752: error: `_Rb_tree' was not declared in this scope
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:752: error: expected primary-expression before ',' token
C:/development/compilers/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_tree.h:752: error: expected primary-expression before ',' token
Process terminated with status 1 (0 minutes, 2 seconds)
52 errors, 0 warnings
 
--- End code ---

TDragon:
Missing or corrupted MinGW files, or a weird command line. The code works fine for me (admittedly, I am using 3.4.2).

MortenMacFly:
Please provide a full source code file if you want help. The code snippet is not enough. A very "Hello World" application using maps works for me, too. (Sorry.)
With regards, Morten.

jmccay:
The only thing different/missing is the standard console application.  That is all the code left.  I commented out the rest.  Is there some sort of cache?  I did a clean.  I used the template provided for that.  Morten, what version of mingw are you using?

Here is the complete file:

--- Code: ---/**************************************************************************
File: ptl_interfaces.h
Author: Joseph L. McCay
Date: 03/14/2006
Copywrite 2006 All rights reserved
Purpose: This file contains all the interfaces for the Persistence Template Library.

//TODO: Decide on license and place it here.
**************************************************************************/

//TODO decide on how to declare includes!!!



//namespace ptl {
//    #include <string>
#include <string>
#include <utility>
#include <map>
using namespace std;

typedef map<std::string,int> objPropsMap;

    /**
     CLASS: IPerData
     PURPOSE: This interface is used to pass the properties map to the object requirng persistence services.
    */

/*
    class IPerData {
        bool setData(std::map<char,int>& rdata)=0;
        std::map<int,int>& getData()=0;
    };
*/


    /**
     CLASS: IMapper
     PURPOSE: All mapper objects must implement this interface!
    */
/*
    class IMapper {
        bool connect(int num, boost::any *pAny = NULL)=0;
        bool disconnect()=0;
        bool write()=0;
        bool Write(IPerData *)=0;
        std::map<int,int>& read()=0;
        bool read(IPerData*)=0;
        bool Bind()=0;
    };
*/
//}

--- End code ---

I commented everything else out.  It is strange because if I create a new file with just that information I gave you, it compiles for me too.  What's different?

jmccay

Michael:

--- Quote from: jmccay on March 15, 2006, 03:56:14 am ---The following code gives me 52 errors.  I am using mingw 3.4.5, and I got the same results with 3.4.4.  What am I missing?


--- Code: --- #include <map>
#include <string>
using namespace std;

typedef std::map<string,int> objPropsMap;

--- End code ---

--- End quote ---

Hello,

It works fine here with GCC 4.1.0. Anyway, it is not necessary to use std:: in front of std::map<string,int> objPropsMap, because you declare already using namespace std;.

Anyway, it is you that posted to Mingw-users list, right  :)? As someone replied you it is possible that your problem is not in the map, but elsenwhere:


--- Quote ---What is ptl_interfaces.h?  It's not referenced in your testcase and it's not any part of the mingw tools[...]

--- End quote ---

If you post the source code, it would help :).

Best wishes,
Michael

Navigation

[0] Message Index

[#] Next page

Go to full version