【问题标题】:Google Protobuf 'compiler is out of heap space'Google Protobuf '编译器堆空间不足'
【发布时间】:2014-08-06 14:22:03
【问题描述】:

我使用 protoc.exe 工具生成了 .h 和 .cc,当我将 pb.h 包含在我的解决方案中时,它无法编译

test.pb.h(17): 致命错误 C1060: 编译器堆空间不足

我添加了/Zm 选项(我尝试了所有因素,即/Zm2000/Zm200/Zm1000 等...

但错误仍然出现......

有什么想法吗?因为我有点卡住了,

谢谢!

原型文件:

 package MSGTest;

 enum EnumMsg
 {
    EMF_A  = 1;
    EMF_B  = 2;
 }

 message MSGExtended
 {
     enum MSG_TYPE
     {
        MSGT_SP = 1;
     }

    required  MSG_TYPE type = 1;
 }

 message MSGExtended2
 {
     enum MSG_TYPE
     {
        MSGT_SP = 1;
     }

    required  MSG_TYPE type = 1;
 }

 message MSGExtendedb
 {
    required EnumMsg        from = 1; 
    optional MSGExtended    msga = 2;
    optional MSGExtendedb   msgb = 3;
 }

【问题讨论】:

  • 查看生成的文件。是否有无限递归包含之类的?是所有 protobuf 文件都发生这种情况,还是只是一个特别复杂的文件?
  • 您的标题也显示为 Visual Studio 2012(或已使用),但您使用了 visual-studio-2013 标记。您是否发现这两个版本都有这个问题?
  • 抱歉,我只用 Visual Studio 2012 测试这个,protobuf 很简单,发布它有问题
  • MSGExtendedb 包含自己?是不是打算改为MSGExtended2
  • 知道这个问题是发生在任何其他协议上还是只发生在这个特定协议上仍然会有所帮助。

标签: visual-c++ visual-studio-2012 protocol-buffers


【解决方案1】:

自动生成的 *.pb.h 文件中的第 17 行始终相同,它是

#error This file was generated by an older version of protoc which is

或与相邻块一起:

#if GOOGLE_PROTOBUF_VERSION < 2004000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please update
#error your headers.
#endif
#if 2004000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers.  Please
#error regenerate this file with a newer version of protoc.
#endif

只要上述两个条件中的任何一个为真,VS2012(在我的例子中)就不会打印错误消息,而是放弃误导性的“致命错误 C1060:编译器堆空间不足”。 条件为真的原因是我的系统有点混乱:c:/opt/bin 包含较旧的 protoc.exe(版本 2.4.0),而包含 GOOGLE_PROTOBUF_VERSION 和 GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 定义的版本为 2.5.1(2005001 ),使第二个条件为真。 将正确的 protoc.exe 复制到 c:/opt/bin 即可解决问题。

【讨论】:

    猜你喜欢
    • 2022-01-21
    • 1970-01-01
    • 2014-07-17
    • 2012-06-15
    • 1970-01-01
    • 1970-01-01
    • 2011-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多