解决proto文件转换时提示“Note that enum values use C++ scoping rules, meaning that enum values are siblings of their type, not children of it. ”


前言:

想将.proto文件转换成.pb文件时一直报错,一开始以为是文件编码格式的问题,后来将文件改成windows下的utf-8格式后,又出现了新的报错(见下图)。百度了很久,才找到解决方法。

“Note that enum values use C++ scoping rules, meaning that enum values are siblings of their type, not children of it. ”这个报错的意思是:在所有pb文件中必须是唯一的,而不仅仅是在这个enum中唯一。反过来理解就是enum中的属性名定义必须是唯一的。

 

解决方法:

1.如果提示已经存在了,就将enum里的属性名改个唯一的名字咯

 

2.谷歌官方文档里还有一个解决方法:

在这个enum中添加option allow_alias = true;

 

 

具体的可以查看https://developers.google.com/protocol-buffers/docs/proto3

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM