Skip to content

Building with gcc 4.8 #42

Closed
Closed

Description

@Luthaf

I needed to build docopt using GCC 4.8, because this is default compiler in CentOS 7.

GCC 4.8 C++11 support is good, but all the <regex> functionalities are missing. So I created a fallback to Boost.Regex when building with GCC 4.8, and used C++11 regex in all other cases.

I used the following diff:

diff --git a/docopt.cpp b/docopt.cpp
index 2fd5f42..ce983c5 100644
--- a/docopt.cpp
+++ b/docopt.cpp
@@ -17,9 +17,24 @@
 #include <unordered_map>
 #include <map>
 #include <string>
-#include <regex>
 #include <iostream>
 #include <cassert>
 #include <cstddef>

+#ifdef DOCOPT_USES_BOOST_REGEX
+#include <boost/regex.hpp>
+namespace std {
+   using boost::regex;
+   using boost::sregex_iterator;
+   using boost::smatch;
+   using boost::regex_search;
+   namespace regex_constants {
+       using boost::regex_constants::match_not_null;
+   }
+}
+#else
+#include <regex>
+#endif

If you want to include this in docopt, I can do a PR.

Activity

  1. jaredgrubb commented on Mar 16, 2016

    @jaredgrubb
    Member

    Does it work well enough?

  2. Luthaf commented on Mar 16, 2016

    @Luthaf
    ContributorAuthor

    Works well enough for me, with most of the docopt features. I did not ran the test suite, but I can if you are willing to integrate this.

  3. jaredgrubb commented on Mar 16, 2016

    @jaredgrubb
    Member

    Yes, please do. "Working mostly" is still better than "not at all" but if we advertise that it works, I'd like a little more confidence at least.

  4. Luthaf commented on Mar 16, 2016

    @Luthaf
    ContributorAuthor

    Ok, I only got one failure on the test suite. Please see #43 for the changes.

  5. rhd commented on Apr 21, 2016

    @rhd

    I'd like to see the boost fallback on gcc 4.8 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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