主要是这几个错误
/usr/include/c++/11/bits/uniform_int_dist.h:284:71: error: call to non-‘constexpr’ function ‘static uint64_t omp::XoroShiro128Plus::min()’ 284 | constexpr __uctype __urngmin = _UniformRandomBitGenerator::min();
/usr/include/c++/11/bits/uniform_int_dist.h:285:71: error: call to non-‘constexpr’ function ‘static uint64_t omp::XoroShiro128Plus::max()’ 285 | constexpr __uctype __urngmax = _UniformRandomBitGenerator::max();
/usr/include/c++/11/bits/uniform_int_dist.h:286:34: error: non-constant condition for static assertion
286 | static_assert( __urngmin < __urngmax,
下面是完整信息
g++ -O3 -std=c++11 -Wall -Wpedantic -pthread -c -o omp/CombinedRange.o omp/CombinedRange.cpp
In file included from /usr/include/c++/11/bits/stl_algo.h:66,
from /usr/include/c++/11/algorithm:62,
from omp/CombinedRange.cpp:4:
/usr/include/c++/11/bits/uniform_int_dist.h: In instantiation of ‘std::uniform_int_distribution<_IntType>::result_type std::uniform_int_distribution<_IntType>::operator()(_UniformRandomBitGenerator&, const std::uniform_int_distribution<_IntType>::param_type&) [with _UniformRandomBitGenerator = omp::XoroShiro128Plus; _IntType = long unsigned int; std::uniform_int_distribution<_IntType>::result_type = long unsigned int]’:
/usr/include/c++/11/bits/stl_algo.h:3791:35: required from ‘void std::shuffle(_RAIter, _RAIter, _UGenerator&&) [with _RAIter = __gnu_cxx::__normal_iterator<omp::CombinedRange::Combo*, std::vector<omp::CombinedRange::Combo, omp::AlignedAllocatoromp::CombinedRange::Combo > >; _UGenerator = omp::XoroShiro128Plus&]’
omp/CombinedRange.cpp:101:17: required from here
/usr/include/c++/11/bits/uniform_int_dist.h:284:71: error: call to non-‘constexpr’ function ‘static uint64_t omp::XoroShiro128Plus::min()’
284 | constexpr __uctype __urngmin = _UniformRandomBitGenerator::min();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from omp/CombinedRange.cpp:3:
omp/Random.h:32:21: note: ‘static uint64_t omp::XoroShiro128Plus::min()’ declared here
32 | static uint64_t min()
| ^
In file included from /usr/include/c++/11/bits/stl_algo.h:66,
from /usr/include/c++/11/algorithm:62,
from omp/CombinedRange.cpp:4:
/usr/include/c++/11/bits/uniform_int_dist.h:285:71: error: call to non-‘constexpr’ function ‘static uint64_t omp::XoroShiro128Plus::max()’
285 | constexpr __uctype __urngmax = _UniformRandomBitGenerator::max();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from omp/CombinedRange.cpp:3:
omp/Random.h:37:21: note: ‘static uint64_t omp::XoroShiro128Plus::max()’ declared here
37 | static uint64_t max()
| ^
In file included from /usr/include/c++/11/bits/stl_algo.h:66,
from /usr/include/c++/11/algorithm:62,
from omp/CombinedRange.cpp:4:
/usr/include/c++/11/bits/uniform_int_dist.h:286:34: error: non-constant condition for static assertion
286 | static_assert( __urngmin < __urngmax,
| ~~~~~~^~~~~~~~~
make: *** [<builtin>: omp/CombinedRange.o] Error 1
1
elfive 2022-07-27 18:43:07 +08:00 via iPhone
1. 把 min()和 max()函数里调用_UniformRandomBitGenerator::min()和_UniformRandomBitGenerator::max();的定义去掉 constexpr 修饰。
2. static_assert 改为 assert |
2
hhhhhh123 OP @elfive 我是要 修改 /usr/include/c++/11/bits/uniform_int_dist 这些底层文件是吗? 修改后 会对其他代码编译什么的受影响吗
|
3
hhhhhh123 OP @elfive 方法 1 成功解决一部分,但是方法 2 好像不行还是报错了 出现了两个新的错误
In file included from /usr/include/c++/11/bits/stl_algo.h:66, from /usr/include/c++/11/algorithm:62, from omp/CombinedRange.cpp:4: /usr/include/c++/11/bits/uniform_int_dist.h:286:96: error: macro "assert" passed 2 arguments, but takes just 1 286 | assert( __urngmin < __urngmax, "Uniform random bit generator must define min() < max()"); niform_int_distribution<_IntType>::param_type&)’: /usr/include/c++/11/bits/uniform_int_dist.h:286:9: error: ‘assert’ was not declared in this scope 286 | assert( __urngmin < __urngmax, "Uniform random bit generator must define min() < max()"); |
4
hhhhhh123 OP @elfive static_assert( __urngmin < __urngmax, "Uniform random bit generator must define min() < max()");
我删除 static_ 后 就是上面的报错 |
5
elfive 2022-07-28 10:26:28 +08:00 via iPhone
|
7
hhhhhh123 OP @elfive 这是修改后的
__uctype __urngmin = _UniformRandomBitGenerator::min(); __uctype __urngmax = _UniformRandomBitGenerator::max(); assert( __urngmin < __urngmax); 报错信息变多了.... g++ -O3 -std=c++11 -Wall -Wpedantic -pthread -c -o omp/EquityCalculator.o omp/EquityCalculator.cpp In file included from omp/EquityCalculator.cpp:1: omp/EquityCalculator.h:76:21: error: ‘std::function’ has not been declared 76 | std::function<void(const Results&)> callback = nullptr, | ^~~~~~~~ omp/EquityCalculator.h:76:29: error: expected ‘,’ or ‘...’ before ‘<’ token 76 | std::function<void(const Results&)> callback = nullptr, | ^ omp/EquityCalculator.h:202:10: error: ‘function’ in namespace ‘std’ does not name a template type 202 | std::function<void(const Results& results)> mCallback; | ^~~~~~~~ omp/EquityCalculator.h:15:1: note: ‘std::function’ is defined in header ‘<functional>’; did you forget to ‘#include <functional>’? 14 | #include <unordered_map> +++ |+#include <functional> 15 | #include <array> omp/EquityCalculator.h:76:16: error: default argument missing for parameter 6 of ‘bool omp::EquityCalculator::start(const std::vector<omp::CardRange>&, uint64_t, uint64_t, bool, double, int)’ 76 | std::function<void(const Results&)> callback = nullptr, | ^~~~~~~~~~~~~ omp/EquityCalculator.h:74:67: note: ...following parameter 2 which has a default argument 74 | bool start(const std::vector<CardRange>& handRanges, uint64_t boardCards = 0, uint64_t deadCards = 0, | ~~~~~~~~~^~~~~~~~~~~~~~ omp/EquityCalculator.cpp:14:74: error: ‘std::function’ has not been declared 14 | bool enumerateAll, double stdevTarget, std::function<void(const Results&)> callback, | ^~~~~~~~ omp/EquityCalculator.cpp:14:82: error: expected ‘,’ or ‘...’ before ‘<’ token 14 | bool enumerateAll, double stdevTarget, std::function<void(const Results&)> callback, | ^ omp/EquityCalculator.cpp: In member function ‘bool omp::EquityCalculator::start(const std::vector<omp::CardRange>&, uint64_t, uint64_t, bool, double, int)’: omp/EquityCalculator.cpp:47:5: error: ‘mCallback’ was not declared in this scope 47 | mCallback = callback; | ^~~~~~~~~ omp/EquityCalculator.cpp:47:17: error: ‘callback’ was not declared in this scope; did you mean ‘calloc’? 47 | mCallback = callback; | ^~~~~~~~ | calloc omp/EquityCalculator.cpp:48:23: error: ‘updateInterval’ was not declared in this scope; did you mean ‘mUpdateInterval’? 48 | mUpdateInterval = updateInterval; | ^~~~~~~~~~~~~~ | mUpdateInterval omp/EquityCalculator.cpp:51:9: error: ‘threadCount’ was not declared in this scope 51 | if (threadCount == 0) | ^~~~~~~~~~~ omp/EquityCalculator.cpp:53:26: error: ‘threadCount’ was not declared in this scope 53 | mUnfinishedThreads = threadCount; | ^~~~~~~~~~~ omp/EquityCalculator.cpp: In member function ‘void omp::EquityCalculator::updateResults(const omp::EquityCalculator::BatchResults&, bool)’: omp/EquityCalculator.cpp:740:13: error: ‘mCallback’ was not declared in this scope 740 | if (mCallback) | ^~~~~~~~~ make: *** [<builtin>: omp/EquityCalculator.o] Error 1 |
8
elfive 2022-07-28 15:29:59 +08:00 via iPhone
|
10
hhhhhh123 OP @elfive 在上面写了
#ifndef _GLIBCXX_BITS_UNIFORM_INT_DIST_H #define _GLIBCXX_BITS_UNIFORM_INT_DIST_H #include <type_traits> #include <ext/numeric_traits.h> #if __cplusplus > 201703L # include <concepts> #endif #include <bits/concept_check.h> // __glibcxx_function_requires #include <functional> 但是错误好像还是这个 |
11
hhhhhh123 OP @elfive
In file included from omp/EquityCalculator.cpp:1: omp/EquityCalculator.h:76:21: error: ‘std::function’ has not been declared 76 | std::function<void(const Results&)> callback = nullptr, | ^~~~~~~~ omp/EquityCalculator.h:76:29: error: expected ‘,’ or ‘...’ before ‘<’ token 76 | std::function<void(const Results&)> callback = nullptr, | ^ omp/EquityCalculator.h:202:10: error: ‘function’ in namespace ‘std’ does not name a template type 202 | std::function<void(const Results& results)> mCallback; | ^~~~~~~~ omp/EquityCalculator.h:15:1: note: ‘std::function’ is defined in header ‘<functional>’; did you forget to ‘#include <functional>’? 14 | #include <unordered_map> +++ |+#include <functional> 15 | #include <array> omp/EquityCalculator.h:76:16: error: default argument missing for parameter 6 of ‘bool omp::EquityCalculator::start(const std::vector<omp::CardRange>&, uint64_t, uint64_t, bool, double, int)’ 76 | std::function<void(const Results&)> callback = nullptr, | ^~~~~~~~~~~~~ omp/EquityCalculator.h:74:67: note: ...following parameter 2 which has a default argument 74 | bool start(const std::vector<CardRange>& handRanges, uint64_t boardCards = 0, uint64_t deadCards = 0, | ~~~~~~~~~^~~~~~~~~~~~~~ omp/EquityCalculator.cpp:13:6: error: no declaration matches ‘bool omp::EquityCalculator::start(const std::vector<omp::CardRange>&, uint64_t, uint64_t, bool, double, std::function<void(const omp::EquityCalculator::Results&)>, double, unsigned int)’ 13 | bool EquityCalculator::start(const std::vector<CardRange>& handRanges, uint64_t boardCards, uint64_t deadCards, | ^~~~~~~~~~~~~~~~ In file included from omp/EquityCalculator.cpp:1: omp/EquityCalculator.h:74:10: note: candidate is: ‘bool omp::EquityCalculator::start(const std::vector<omp::CardRange>&, uint64_t, uint64_t, bool, double, int)’ 74 | bool start(const std::vector<CardRange>& handRanges, uint64_t boardCards = 0, uint64_t deadCards = 0, | ^~~~~ omp/EquityCalculator.h:22:7: note: ‘class omp::EquityCalculator’ defined here 22 | class EquityCalculator | ^~~~~~~~~~~~~~~~ omp/EquityCalculator.cpp: In member function ‘void omp::EquityCalculator::updateResults(const omp::EquityCalculator::BatchResults&, bool)’: omp/EquityCalculator.cpp:740:13: error: ‘mCallback’ was not declared in this scope 740 | if (mCallback) | ^~~~~~~~~ make: *** [<builtin>: omp/EquityCalculator.o] Error 1 |