J
.J.T.
Hello all,
I have a strange error when try to use map<int, string> (using gcc
version 2.95.2).
I have this code in header file (display_map.h):
#ifndef DISPLAY_MAP_H
#define DISPLAY_MAP_H
#include <map>
#include <string>
typedef map<int,string> display_map;
display_map DM;
DM[0]=" ";
DM[1]="o";
DM[2]=".";
#endif
The main program is that simple:
#include "display_map.h"
int main(){
return 0;
}
and the error goes:
---------------------------
display_map.h:9: ANSI C++ forbids declaration `DM' with no type
display_map.h:9: conflicting types for `int DM[0]'
display_map.h:8: previous declaration as `class display_map DM'
display_map.h:9: invalid initializer
....
(and the same about DM[1], DM[2])
...
cc1plus: register name not specified for ` /* decl error */ '
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3/stl_map.h:76:
Internal compiler error in `make_decl_rtl', at varasm.c:738
Please submit a full bug report.
-----------------------------
Why "declaration `DM' with no type"?
What "conflicting types"?
Where "previous declaration"?
Is this some kind of gcc bug, or is there something I don't know about
map usege?
I have a strange error when try to use map<int, string> (using gcc
version 2.95.2).
I have this code in header file (display_map.h):
#ifndef DISPLAY_MAP_H
#define DISPLAY_MAP_H
#include <map>
#include <string>
typedef map<int,string> display_map;
display_map DM;
DM[0]=" ";
DM[1]="o";
DM[2]=".";
#endif
The main program is that simple:
#include "display_map.h"
int main(){
return 0;
}
and the error goes:
---------------------------
display_map.h:9: ANSI C++ forbids declaration `DM' with no type
display_map.h:9: conflicting types for `int DM[0]'
display_map.h:8: previous declaration as `class display_map DM'
display_map.h:9: invalid initializer
....
(and the same about DM[1], DM[2])
...
cc1plus: register name not specified for ` /* decl error */ '
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3/stl_map.h:76:
Internal compiler error in `make_decl_rtl', at varasm.c:738
Please submit a full bug report.
-----------------------------
Why "declaration `DM' with no type"?
What "conflicting types"?
Where "previous declaration"?
Is this some kind of gcc bug, or is there something I don't know about
map usege?