0
    auto s = fxMessageResponse.SerializeAsString(); //this returns std::string
    std::vector<const int8_t> bytes(s.size());
    std::copy( s.begin(), s.end(), std::back_inserter(bytes));

This is giving the famous lots of errors like

  /home/lz/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/memory:1699:31: error: cannot initialize a parameter of type 'void *' with an lvalue of type 'const signed char *'
                  _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));

As far as I know, int8_t and char are the same for Armv8a. Why do I get this error?

Guerlando OCs
  • 1,886
  • 9
  • 61
  • 150
  • 1
    You can't have a `std::vector` of `const` objects, see https://stackoverflow.com/questions/17313062/vector-of-const-objects-giving-compile-error. But without that it seems to compile fine, as in https://godbolt.org/z/4KWKhT – Nate Eldredge Dec 29 '20 at 01:54
  • 1
    Besides the problem explained in the linked question, you also have another bug. You construct a vector that already has `s.size()` values in it, and then proceed to add ***more*** stuff to it. That's clearly not your intent here. You must fix both issues to make this work. – Sam Varshavchik Dec 29 '20 at 01:54
  • 1
    *As far as I know, int8_t and char are the same for Armv8a* -- There is no need to guess. That test can be done at compile-time: `static_assert(sizeof(int8_t) == sizeof(char), "Sorry, types are not equal size");` – PaulMcKenzie Dec 29 '20 at 02:08
  • A `char` is often a `signed char`. It sometimes (very rarely) isn't. I suggest `std::vector`. Why make them `const`? – Ted Lyngmo Dec 29 '20 at 02:19

0 Answers0