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 ...
随机推荐
- 07 c++中的内联函数inline
文章链接: 问题描述:类中成员函数缺省默认是内联的,如果在类定义时就在类内给出函数定义,那当然最好.如果在类中未给出成员函数定义,而又想内联该函数的话,那在类外要加上 inline,否则就认为不是内联 ...
- 图解TCP/IP笔记
- Openwrt路由器上开发微信公众号应用
利用nohup命令创建启动服务 nohup, /dev/null 2>&1,输出重定向 http://www.cnblogs.com/taosim/articles/2610170.ht ...
- asp.net实现大文件上传分片上传断点续传
HTML部分 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.a ...
- 洛谷P1038 神经网络题解
注意如果是 \(if(c[i])\) 这条语句并没有说明c[i]不为负数,所以说最好老老实实的写 #include<cstdio> #define _ 0 using namespace ...
- ZR#984
ZR#984 解法: 异或的一个性质: $ a+b \geq a \bigoplus b$ 所以一边读入一边把读进来的值加到答案就行了. #include<iostream> #inclu ...
- SpringMVC的处理器全局异常处理类
SpringMVC的处理器全局异常处理类 package com.huawei.utils; import org.springframework.web.servlet.HandlerExcepti ...
- spring boot 之注册
注册数据库 使用spring boot 之登录笔记 的数据库 在server 层 User create(String username, String password, String email ...
- ubuntu之路——day8.5 学习率衰减learning rate decay
在mini-batch梯度下降法中,我们曾经说过因为分割了baby batch,所以迭代是有波动而且不能够精确收敛于最小值的 因此如果我们将学习率α逐渐变小,就可以使得在学习率α较大的时候加快模型训练 ...
- No module named 'lsb_release'
python3.7安装后提示 No module named 'lsb_release' 修改"/usr/bin/lsb_release" #!/usr/bin/python3.5 ...