]> sigrok.org Git - libsigrok.git/blobdiff - configure.ac
bindings/cxx: implement std::stoul() fallback when C++11 is missing
[libsigrok.git] / configure.ac
index c98c55a4808b9921bce93e245134afdf481993ed..3ba6c8c5df6dd3e42bcce5c03f27c370da03e19a 100644 (file)
@@ -465,6 +465,16 @@ AM_COND_IF([BINDINGS_CXX], [
        AS_IF([test "x$sr_cv_have_stoi_stod" = xyes],
                [AC_DEFINE([HAVE_STOI_STOD], [1],
                        [Specifies whether we have the stoi and stod functions.])])
+       # In theory std::stoul() should have identical availability
+       # as std::stoi() and std::stod() have. All of them are C++11.
+       # But we play it safe here, and check support individually.
+       AC_CACHE_CHECK([for stoul], [sr_cv_have_stoul],
+               [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string>]],
+                               [[(void) std::stoul("1");]])],
+                       [sr_cv_have_stoul=yes], [sr_cv_have_stoul=no])])
+       AS_IF([test "x$sr_cv_have_stoul" = xyes],
+               [AC_DEFINE([HAVE_STOUL], [1],
+                       [Specifies whether we have the std::stoul function.])])
 ])
 
 #######################