Skip to content

sparseconfig.h should not vary based on C++11 capability #145

@ryandesign

Description

@ryandesign

In sparsehash 2.0.3, the installed sparseconfig.h varies based on whether or not the compiler used to compile sparsehash had full C++11 capabilities. Specifically, here is the difference in that header between a machine running OS X 10.8 (a.k.a. Darwin 12), which uses libstdc++ by default which doesn't have a full C++11 implementation and uses tr1, and one running OS X 10.9 (a.k.a. Darwin 13), which uses libc++ by default which does have a full C++11 implementation and doesn't use tr1:

--- sparsehash-2.0.3_0.darwin_12.x86_64/opt/local/include/sparsehash/internal/sparseconfig.h	2015-10-17 10:41:02.000000000 -0500
+++ sparsehash-2.0.3_0.darwin_13.x86_64/opt/local/include/sparsehash/internal/sparseconfig.h	2015-10-17 10:40:37.000000000 -0500
@@ -7,10 +7,10 @@
 #define GOOGLE_NAMESPACE ::google
 
 /* the location of the header defining hash functions */
-#define HASH_FUN_H <tr1/functional>
+#define HASH_FUN_H <functional>
 
 /* the namespace of the hash<> function */
-#define HASH_NAMESPACE std::tr1
+#define HASH_NAMESPACE std
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #define HAVE_INTTYPES_H 1

This causes problems. Although OS X 10.8 defaults to libstdc++, it has libc++ available. Imagine I want to compile a program (textmate 2.0-rc.4) that requires sparsehash and it requires libc++, so it uses -stdlib=libc++. It fails to build with:

In file included from Shared/PCH/prelude.cc:26:
/opt/local/include/sparsehash/dense_hash_map:106:10: fatal error: 'tr1/functional' file not found
#include HASH_FUN_H                 // for hash<>
         ^
/opt/local/include/sparsehash/internal/sparseconfig.h:10:20: note: expanded from macro 'HASH_FUN_H'
#define HASH_FUN_H <tr1/functional>
                   ^~~~~~~~~~~~~~~~
1 error generated.

Please install a sparseconfig.h that can be used without modification with both C++11 and pre-C++11 toolchains, since some systems have and need to be able to use both. Use preprocessor directives to pick the right HASH_FUN_H and HASH_NAMESPACE at build time when sparseconfig.h is used, not when it is installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions