Solaris上的Proto“多声明i”错误

时间:2011-11-11 14:26:54

标签: c++ solaris protocol-buffers

我正在尝试构建一个使用从Solaris上的proto文件生成的protobuf cc文件的c ++代码,但是我收到错误“我的多个声明”。

是否有任何解决方法可以强制proto不在CC上生成多个“i”声明或编译器标志来忽略它?

proto生成的代码是:

 // repeated double Prices = 22;
  for (int i = 0; i < this->prices_size(); i++) {
    ::google::protobuf::internal::WireFormatLite::WriteDouble(
      22, this->prices(i), output);
  }

  // repeated double Yields = 23;
  for (int i = 0; i < this->yields_size(); i++) {
    ::google::protobuf::internal::WireFormatLite::WriteDouble(
      23, this->yields(i), output);
  }

这会触发错误。

谢谢, 波格丹

2 个答案:

答案 0 :(得分:2)

看起来编译器期待预标准的C ++。根据文档,如果在编译器的命令行中指定-compat-compat=4,则会发生这种情况,因此请确保您没有这样做。

答案 1 :(得分:1)

您使用的是哪个版本的编译器?如果指定-features=localfor,则应该具有正确的行为,但至少在当前版本的编译器中,除非您指定-compat=4,否则这是默认行为。 (但如果出于其他原因需要-compat=4,您仍然可以指定-features=localfor。)