#include <google/sparse_hash_map>
using namespace google;
int main(int argc, char* argv[]) {
sparse_hash_map<unsigned long long, unsigned int> test;
}
sparse_hash_map:133: parse error before `<'
sparse_hash_map:147: `SelectKey' was not declared in this scope
sparse_hash_map:147: `EqualKey' was not declared in this scope
sparse_hash_map:147: `Alloc' was not declared in this scope
sparse_hash_map:147: syntax error before `;'
sparse_hash_map:148: syntax error before `;'
sparse_hash_map:152: confused by earlier errors, bailing out
the library was configured with --enable-namespace=google
The question is why is it trying to compile the template before a call
is made? I understood that compilation of templates is on-demand.
And here's the complete config.h
/* src/google/sparsehash/config.h. Generated by configure. */
/* src/google/sparsehash_config.h.in. Generated from configure.ac by
autoheader. */
/* Namespace for Google classes */
#define GOOGLE_NAMESPACE google
/* the namespace of hash_map */
#define HASH_NAMESPACE std
/* Define to 1 if you have the <ext/hash_fun.h> header file. */
/* #undef HAVE_EXT_HASH_FUN_H */
/* define if the compiler has hash_map */
/* #undef HAVE_EXT_HASH_MAP */
/* define if the compiler has hash_set */
/* #undef HAVE_EXT_HASH_SET */
/* Define to 1 if you have the <ext/stl_hash_fun.h> header file. */
/* #undef HAVE_EXT_STL_HASH_FUN_H */
/* Define to 1 if you have the <hash_fun.h> header file. */
/* #undef HAVE_HASH_FUN_H */
/* define if the compiler has hash_map */
#define HAVE_HASH_MAP 1
/* define if the compiler has hash_set */
#define HAVE_HASH_SET 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `memcpy' function. */
#define HAVE_MEMCPY 1
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* define if the compiler implements namespaces */
#define HAVE_NAMESPACES 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <stl_hash_fun.h> header file. */
#define HAVE_STL_HASH_FUN_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Name of package */
#define PACKAGE "sparsehash"
/* Define to the address where bug reports for this package should be
sent. */
#define PACKAGE_BUGREPORT "opens...@google.com"
/* Define to the full name of this package. */
#define PACKAGE_NAME "sparsehash"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "sparsehash 0.1"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "sparsehash"
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.1"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* the namespace where STL code like vector<> is defined */
#define STL_NAMESPACE std
/* does STL support iterator-tags? */
#define UNDERSTANDS_ITERATOR_TAGS 1
/* Version number of package */
#define VERSION "0.1"
/* Stops putting the code inside the Google namespace */
#define _END_GOOGLE_NAMESPACE_ };
/* Puts following code inside the Google namespace */
#define _START_GOOGLE_NAMESPACE_ namespace GOOGLE_NAMESPACE {
configure: WARNING: stl_hash_fun.h: present but cannot be compiled
configure: WARNING: stl_hash_fun.h: check for missing prerequisite
headers?
configure: WARNING: ## ------------------------------------ ##
configure: WARNING: ## Report this to bug-au...@gnu.org. ##
configure: WARNING: ## ------------------------------------ ##
Also, i tried compiling my test program with gcc 3.3.4 (earlier it was
2.95.3)
and i get
In file included from ......./sparse_hash_map:81,
from MapperTest.cpp:4:
....../google/sparsehash/hash_fun.h:1:26: stl_hash_fun.h: No such file
or directory
followed by earlier errors.
So the error is due to
class HashFcn = HASH_NAMESPACE::hash<Key> (?)
I recompiled the library with g++ 3.3.4 and also all subsequent test
programs. That fixed it.
Interestingly make fails with gcc 3.3.4 (!!)
and configure is incorrect with gcc 2.95.3 (!)
Thank you for you help.
I found out that if the files stl_algobase.h and stl_function.h are
included in that order before including the sparse hash map files, the
compiler is happy. Any idea what is going on?
Thanks for your time.
Here is my test program
#include <iostream>
#include <stl_algobase.h>
#include <stl_function.h>
#include "google/sparsetable"
#include "google/sparse_hash_map"
int main()
{
std::sparsetable<int> test(100);
test[0] = 1000000;
std::cout << test[0] << endl;
std::cout << test[1] << endl;
std::cout << test.size() << endl;
std::cout << test.test(0) << endl;
std::cout << test.test(1) << endl;
std::sparse_hash_map<unsigned int, unsigned int> trial;
}