简体   繁体   中英

I keep getting an "error: constexpr variable 'x' must be initialized by a constant expression" from previously used working code

I've been scratching my head for days now. Gone step by step removing and adding lines and recompiling at each stage until it breaks.

  ACTION act1( name nm, uint64_t ammount );
  ACTION act2(name nm, uint64_t signing_value);
  ACTION receiverand(name nm, checksum256& random_value);
  ACTION act4(name nm, uint64_t stake);
  ACTION act5(uint64_t num);
  ACTION act6(name nm);

  using act1_action = action_wrapper<"act1"_n, &project::act1>;
  using act2_action = action_wrapper<"act2"_n, &project::act2>;
  using receiverand_action = action_wrapper<"receiverand"_n, &project::receiverand>;
  using act4_action = action_wrapper<"act4"_n, &project::act4>;
  using act5_action = action_wrapper<"act5"_n, &project::act5>;
  using act6_action = action_wrapper<"act6"_n, &project::act6>;

The problem arises when I add act6. I had up to act4 and everything was working. So I added 5 and 6 then the error was thrown so I went back added 5 and things were still okay. Here is the error I keep getting

 error: constexpr variable 'x' must be initialized by a constant expression
        constexpr auto x = 
        eosio::name{std::string_view{eosio::detail::to_const_char_arr<Str...>::value, 
        sizeof...(Str)}};

  note: in instantiation of function template specialization 'operator""_n<char, 'a', 
        'c', 't', '6'>' requested here
        using act6_action = action_wrapper<"act6"_n, &project::act6>;

 note: non-constexpr function 'check' cannot be used in a constant expression
       eosio::check( false, "character is not in allowed character set for names" );

Appears that a name cannot contain the character '6' , but only '1' thru '5' .

 Action names [...] May contain: az, 1-5, or.

https://eosio.stackexchange.com/questions/7/what-are-naming-rules-for-actions-tables-and-contracts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM