I am trying to implement hash_multimap in C++. Here is the code:
#include <hash_map>
#include<iostream>
#include <string>
#include <hashtable.h>
#include <hash_set>
#include <stdlib.h>
#include <stdio.h>
struct eqstr{
bool operator()(const char *s1,const char* s2)const{
return strcmp(s1,s2)==0;
}
};
typedef hash_multimap<const char*, int, hash<const char*>, eqstr> map_type;
int main() {
return (EXIT_SUCCESS);
}
But here is the mistake:
usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/david/NetBeansProjects/hash_multimap'
/usr/bin/make -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/hash_multimap
make[2]: Entering directory `/home/david/NetBeansProjects/hash_multimap'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
from main.cpp:1:
In file included from /usr/include/c++/4.4/backward/hash_map:60,
/usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
main.cpp: In member function ‘bool eqstr::operator()(const char*, const char*) const’:
main.cpp:10: error: ‘strcmp’ was not declared in this scope
main.cpp: At global scope:
main.cpp:15: error: expected initializer before ‘<’ token
make[2]: *** [build/Debug/GNU-Linux-x86/main.o] Error 1
make[2]: Leaving directory `/home/david/NetBeansProjects/hash_multimap'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/david/NetBeansProjects/hash_multimap'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
How do I fix this problem?
The problems seem pretty straightforward.
Track down the deprecated header, and look for upgraded packages, libraries, etc. Otherwise, hand-edit the code to update the deprecated header.
main.cpp:10: error: ‘strcmp’ was not declared in this scope
Declare it. Probably by including
string.hA bit less clear, but will probably become clearer as you fix earlier problems. Track down exactly which
<is creating the error, and begin carefully reviewing the definitions ofhash_multimapandhashWhere exactly are you having problems?