【问题标题】:I keep getting an "error: constexpr variable 'x' must be initialized by a constant expression" from previously used working code我不断从以前使用的工作代码中收到“错误:constexpr 变量'x'必须由常量表达式初始化”
【发布时间】:2022-01-11 08:56:36
【问题描述】:

这几天我一直在摸不着头脑。逐步删除和添加行并在每个阶段重新编译,直到它中断。

  ACTION act1(name nm, uint64_t amount);
  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>;

当我添加act6时出现问题。我必须采取行动4,一切正常。所以我加了 5 和 6,然后抛出了错误,所以我又加了 5,一切都还好。 这是我不断收到的错误

 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" );

【问题讨论】:

  • 在 ::act5 中使用 "act6" 并且从不引用 ::act6 时会发生什么?反之亦然? (也就是说,是第一个参数还是第二个参数的问题..?)
  • 你的意思是注释掉“ using act6_action = action_wrapper;"并将act5 行更改为引用act6?像这样:'使用 act5_action = action_wrapper; //使用 act6_action = action_wrapper;'
  • 当然,这是一种变体或检查。
  • 刚刚抛出了这个错误:action not a valid eosio name ACTION act6(name nm);生病尝试将整行更改为 act6 而不仅仅是最后一部分
  • 我尝试了所有变体,它们都抛出了两个错误之一

标签: c++ eos


【解决方案1】:

名称似乎不能包含字符'6',而只能包含'1''5'

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

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

【讨论】:

  • 谢谢!应该意识到这一点。钱包地址只能有 1-5 个
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-14
  • 2023-01-02
相关资源
最近更新 更多