zekyll / OMPEval

Fast C++ poker hand evaluator and equity calculator
ISC License
173 stars 69 forks source link

How to compile on OSX? #14

Open tiltmine opened 6 years ago

tiltmine commented 6 years ago

Trying to compile this on OSX by just typing make, but getting the following:

$ make
c++ -O3 -std=c++11 -Wall -Wpedantic -pthread   -c -o omp/CombinedRange.o omp/CombinedRange.cpp
omp/CombinedRange.cpp:21:47: warning: suggest braces around initialization of subobject [-Wmissing-braces]
        Combo c{1ull << h[0] | 1ull << h[1], {h}, {Hand(h)}};
                                              ^
                                              {}
In file included from omp/CombinedRange.cpp:1:
In file included from omp/CombinedRange.h:4:
In file included from omp/HandEvaluator.h:6:
In file included from omp/Hand.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/array:109:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:2950:57: error: constexpr variable '_Rp'
      must be initialized by a constant expression
    static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min()
                                                        ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:3123:41: note: in instantiation of
      template class 'std::__1::__independent_bits_engine<omp::XoroShiro128Plus, unsigned long long>' requested here
        return static_cast<result_type>(_Eng(__g, _Dt)());
                                        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:3298:35: note: in instantiation of
      function template specialization 'std::__1::uniform_int_distribution<long>::operator()<omp::XoroShiro128Plus>' requested here
            difference_type __i = __uid(__g, _Pp(0, __d));
                                  ^
omp/CombinedRange.cpp:101:10: note: in instantiation of function template specialization
      'std::__1::shuffle<std::__1::__wrap_iter<omp::CombinedRange::Combo *>, omp::XoroShiro128Plus &>' requested here
    std::shuffle(mCombos.begin(), mCombos.end(), rng);
         ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:2950:63: note: non-constexpr function
      'max' cannot be used in a constant expression
    static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min()
                                                              ^
omp/Random.h:37:21: note: declared here
    static uint64_t max()
                    ^
In file included from omp/CombinedRange.cpp:1:
In file included from omp/CombinedRange.h:4:
In file included from omp/HandEvaluator.h:6:
In file included from omp/Hand.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/array:109:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:2953:78: error: non-type template
      argument is not a constant expression
    static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value;
                                                                             ^~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:2953:78: note: initializer of '_Rp' is
      not a constant expression
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:2950:57: note: declared here
    static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min()
                                                        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:2962:69: error: non-type template
      argument is not a constant expression
    result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());}
                                                                    ^~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:3131:15: note: in instantiation of
      member function 'std::__1::__independent_bits_engine<omp::XoroShiro128Plus, unsigned long long>::operator()' requested here
        __u = __e();
              ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:3298:35: note: in instantiation of
      function template specialization 'std::__1::uniform_int_distribution<long>::operator()<omp::XoroShiro128Plus>' requested here
            difference_type __i = __uid(__g, _Pp(0, __d));
                                  ^
omp/CombinedRange.cpp:101:10: note: in instantiation of function template specialization
      'std::__1::shuffle<std::__1::__wrap_iter<omp::CombinedRange::Combo *>, omp::XoroShiro128Plus &>' requested here
    std::shuffle(mCombos.begin(), mCombos.end(), rng);
         ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:2962:69: note: initializer of '_Rp' is
      not a constant expression
    result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());}
                                                                    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:2950:57: note: declared here
    static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min()

1 warning and 3 errors generated.
make: *** [omp/CombinedRange.o] Error 1

Using the following version of c++:

$ c++ -v Apple LLVM version 9.1.0 (clang-902.0.39.2) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Sorry if this is obvious!

anatoly-os commented 6 years ago

Try -std=c++14 or even c++17

jdoerrie commented 6 years ago

Try marking XoroShiro128Plus::max() and ::min() in omp/Random.h as constexpr.