手機 - Motorola XT897 - CM 11 - Debian - 解決Yosys error: ::reallocarray has not been declared問題



問題如下:

In file included from libs/ezsat/../minisat/Solver.h:24,
                 from libs/ezsat/ezminisat.cc:40:
libs/ezsat/../minisat/Vec.h: In member function ‘void Minisat::vec<T, _Size>::capacity(Size)’:
libs/ezsat/../minisat/Vec.h:105:28: error: ‘::reallocarray’ has not been declared
  105 |             ((data = (T*)::reallocarray(data, (cap += add), sizeof(T))) == NULL)
      |                            ^~~~~~~~~~~~
Makefile:728: recipe for target 'libs/ezsat/ezminisat.o' failed
make: *** [libs/ezsat/ezminisat.o] Error 1
make: *** Waiting for unfinished jobs....

解法如下:

$ vim libs/ezsat/../minisat/Vec.h
     98 template<class T, class _Size>
     99 void vec<T,_Size>::capacity(Size min_cap) {
    100     if (cap >= min_cap) return;
    101     Size add = max((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1);   // NOTE: grow by approximately 3/2
    102     const Size size_max = std::numeric_limits<Size>::max();
    103     if ( ((size_max <= std::numeric_limits<int>::max()) && (add > size_max - cap))
    104     ||   (
    105 //#ifdef _DEFAULT_SOURCE
    106 //            ((data = (T*)::reallocarray(data, (cap += add), sizeof(T))) == NULL)
    107 //#else
    108             ((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL)
    109 //#endif
    110     && errno == ENOMEM) )
    111         throw OutOfMemoryException();
    112  }