Deprecated handling includes Autoconf

I used ext::hash_map

C ++ in a project and noticed that in g ++ 4.3 it is deprecated in favor unordered_map

. I need to maintain compatibility with older systems that don't unordered_map

. It occurs to me that this is something that can be handled by autoconf, which I am already using. However, I couldn't find any documentation on this.

I would suggest that I need to do something like the following:
- Replace all instances ext::hash_map

in my code with MY_HASH_MAP


- Replace all instances ext/hash_map

in my code MY_HASH_INCLUDE


- Include a line in configure.ac using some combination AC_CHECK_HEADERS

andAC_DEFINE

I haven't been able to pinpoint the right autoconf magic for this job, and I'm wondering if this is even the best solution. Surely this is something that a lot of other people will be dealing with, and there may be some standard solution that I could not find?

So, three related questions:
- Is there a standard way to handle this that I should use?
- How to do this in autoconf?
- Should I just use -Wno-deprecated and assume that the C ++ standard won't be updated over the course of my life?

+1


a source to share


2 answers


You can use AC_CHECK_HEADERS([my_header_file])

to see what files are present and then create a new one class MyApp::hash_map

, which depending on how defines what defines, wraps the functionality appropriately.



+1


a source


I would consider leaving the code as it is and turning off the "deprecated" warning, especially if you need to support older systems where you only have an ext :: hash_map file available.



IIRC ext :: hash_map is not part of the standard anyway, so the main harm that can be done is that (eventually) maintainers of g ++ will remove support for it. However, if you use the code to include both the hash_map and the tr1 unordered_map, you suddenly redoubled your testing efforts for that particular code. Unless there is a specific reason that might require duplication of effort, save it for something more useful.

0


a source







All Articles