sorry, unimplemented: non-trivial designated initializers not supported
将C语言转换为C++代码时,发生如下错误
sorry, unimplemented: non-trivial designated initializers not supported。
查找原因,是因为C++结构体初始化时,必须按照定义的顺序进行初始化,不能够跳过其中内容而初始化其他选项,或者定义的顺序先后有问题。
eg:
typedef struct command
{
int a;
char *b;
int c;
int d;
};
在C语言中定义时候进行初始化,这个是可以的:
struct command cmd = {
.a = 20,
.c = 3,
};
而在C++语言中会报错,修改方式如下:
struct command cmd = {
.a = 20,
.b = "", // 必须初始化
.c = 3,
};
还有一个就是顺序问题,C++中必须与结构体中定义一致。
eg:
struct command cmd = {
.b = "fff",
.a = 3,
};
C中运行正常,而C++中运行异常,会报标题错误,修改
struct command cmd = {
.a = 3,
.b = "fff",
};
sorry, unimplemented: non-trivial designated initializers not supported的更多相关文章
- swift语言点评十七-Designated Initializers and Convenience Initializers
Swift defines two kinds of initializers for class types to help ensure all stored properties receive ...
- 【转】Android 源码编译make的错误处理--不错
原文网址:http://blog.csdn.net/ithomer/article/details/6977386 Android源码下载:官方下载 或参考android源码下载方式 Android编 ...
- c++ anonymous union,struct -- 匿名联合体和机构体
c++ anonymous union,struct -- 匿名联合体和机构体 结构体和联合体各自的基本用法不赘述,仅说一下他们匿名时访问的情况.如果是token不同,可以直接跨层访问.例子 #inc ...
- C++ struct 初始化的问题
struct student { int age; string name; int id; }; 初始化: student st1={10, "li ming", 01}; 修改 ...
- ios 修正waring:Method override for the designated initializer of the superclass '-init' not found
swift引入后,为了使oc和swift更相近,对oc的初始化方法也进行了修正,具体说明,见下面的链接,这个waring的最简单的修正方法是,到相应类的头文件中,去掉在自定义初始化方法后面的 NS_D ...
- Google C++ Style Guide
Background C++ is one of the main development languages used by many of Google's open-source project ...
- Google C++ 代码规范
Google C++ Style Guide Table of Contents Header Files Self-contained Headers The #define Guard For ...
- iOS 方法修饰符
一.NS_DESIGNATED_INITIALIZER 用来修饰init方法,被修饰的方法称为designated initializer:没有被这个修饰的init方法称为convenience i ...
- Swift3.0P1 语法指南——构造器
原档:https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programmi ...
随机推荐
- SpringBoot序列化时间类型的问题
在使用sringboot的时候因为在配置文件中缺少一个配置项,所以导致查询出来的时间都是long类型的时间格式 因为springboot默认使用的是Jackson 这个时间显然不是我们所需要的,参考官 ...
- jdk1.8换成11,启动项目报错java.net.MalformedURLException: unknown protocol: jrt
jdk11 Information:Internal caches are corrupted or have outdated format, forcing project rebuild: Mo ...
- 【Java】Unicode & UTF-8 & UTF-16 & UTF-32
Unicode Unicode(统一码.万国码.单一码)是计算机科学领域里的一项业界标准,包括字符集.编码方案等.Unicode 是为了解决传统的字符编码方案的局限而产生的,它为每种语言中的每个字符设 ...
- 六.Protobuf3引入其他.proto文件
Protobuf3 使用其他消息类型 您可以使用其他消息类型作为字段类型.例如,假设您希望在每个SearchResponse消息中包含Result消息,为此,您可以在.proto中定义结果消息类型,然 ...
- git submodule 使用小结
git submodule 使用小结 原文链接 http://blog.gezhiqiang.com/2017/03/08/git-submodule/###### Git Submodule 允许一 ...
- IList<> IEnumerable<> ReadOnlyCollection<> 使用方向
无论你把它声明为IList<string>,IEnumerable<string>,ReadOnlyCollection<string>或别的东西,是你...... ...
- 使用socket.io实现多房间通信聊天室
websocket的实现有很多种,像ws和socket.io,这里使用的是socket.io来实现多房间的效果. 这里的使用没有使用socket.io官方提供的namespace和room,而是完全通 ...
- 小程序的基本原生js使用
1.点击事件 <a data-current="{{setting.current}}" bindtap="clickcurrent" style=&qu ...
- tensorflow中的函数获取Tensor维度的两种方法:
获取Tensor维度的两种方法: Tensor.get_shape() 返回TensorShape对象, 如果需要确定的数值而把TensorShape当作list使用,肯定是不行的. 需要调用Tens ...
- 如何写一个webService接口
第一次写接口的时候,感觉太过笼统,压根不知道接口是个什么东东,,后来自己也查了好多资料,才发现其实接口可以就认为是一个方法,自己多写几种以后就会发现挺简单的,自己整理了一下资料,纯属增强自己的记忆,也 ...