I want to define a vector of strings with a fixed size 3 in the multi-index table of smart contract. I search and tried different ways which I found for CPP vector like:

std::vector<string> abc(3);

But didn't worked. Any help would be appreciated.

2 Answers 2


EOSIO.CDT doesn't support std::array in function argument or field of multi_index struct. You can try my customized version of cdt, eoscc which supports std::array.

If you want to use official EOSIO.CDT, you had better use std::vector, but limit the number of items by yourself.


Consider this:

std::array<string, 3> abc;


std::array causes compilation segmentation fault

You can make your own array:

class MyFixedArray {
  int a[3];
  auto begin() {...}
  auto end() {...}

struct [[eosio::table]] TableWithArray {
     MyFixedArray values;

I think it should work. Didn't test that though :)

  • If I use this and compile the smart contract. It generates: Segmentation fault (core dumped)
    – Varsh
    Commented Jun 9, 2020 at 9:18
  • Indeed. Didn't know about that, sorry.
    – Teresa
    Commented Jun 9, 2020 at 13:07
  • If you stuck with this, consider using table/field through custom interface (adaptor).
    – Teresa
    Commented Jun 9, 2020 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.