0

suppose I have:

struct [[eosio::table]] _test {
  asset supply;
  uint64_t primary_key() const {
    return supply.symbol.code().raw();
  }
};
typedef eosio::multi_index<name("test"), _test> test;

and want to build a function like this:

_test* token::test_get(symbol sym)
{
    test t(_self, _self.value);
    auto r = t.find(sym.code().raw());
    eosio_assert(r != t.end(), "No such symbol in test table");
    return r;
}

when I try to compile it complains:

token.cpp:319:2: error: unknown type name '_test'

_test* token::token_get(symbol sym) ^

token.cpp:324:10: error: no viable conversion from returned value of type 'eosio::multi_index<14831598679621632000, eosio::token::_test>::const_iterator' to function return type 'int *' return r;

so obviously I don't have the return type right but why can't it find the struct definition? and what would be the right return type? I find nothing in the docs about how to do this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.