【问题标题】:Forward declarations in CapnProtoCapnProto 中的前向声明
【发布时间】:2018-05-25 07:50:20
【问题描述】:

在 CapnProto 架构中是否有任何方法可以前向声明结构,以便您可以制作这样的树结构:

struct ExecuteProgram {
  code @0 :Text;
}

struct SequenceProgram {
  programs @0 :List(Program)
}

struct IfProgram {
  condition @1 :Program;
  trueBody @2 :Program;
  falseBody @3 :Program;
}

struct Program {
  union {
    execute @0 :ExecuteProgram;
    sequence @1 :SequenceProgram;
    if @2 :IfProgram;
  }
}

如果我尝试编译它,编译器会给出非常有用的错误消息Parse error。我认为它在抱怨是因为我在声明它之前使用了Program

有没有办法解决这个问题?

【问题讨论】:

    标签: capnproto


    【解决方案1】:

    事实证明你不需要前向声明,我只是少了一个分号。我在说 Parse error 是一个可怕的错误消息是什么意思?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-20
      • 2012-03-14
      • 1970-01-01
      • 2016-06-19
      • 2011-05-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多