将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的更多相关文章

  1. swift语言点评十七-Designated Initializers and Convenience Initializers

    Swift defines two kinds of initializers for class types to help ensure all stored properties receive ...

  2. 【转】Android 源码编译make的错误处理--不错

    原文网址:http://blog.csdn.net/ithomer/article/details/6977386 Android源码下载:官方下载 或参考android源码下载方式 Android编 ...

  3. c++ anonymous union,struct -- 匿名联合体和机构体

    c++ anonymous union,struct -- 匿名联合体和机构体 结构体和联合体各自的基本用法不赘述,仅说一下他们匿名时访问的情况.如果是token不同,可以直接跨层访问.例子 #inc ...

  4. C++ struct 初始化的问题

    struct student { int age; string name; int id; }; 初始化: student st1={10, "li ming", 01}; 修改 ...

  5. ios 修正waring:Method override for the designated initializer of the superclass '-init' not found

    swift引入后,为了使oc和swift更相近,对oc的初始化方法也进行了修正,具体说明,见下面的链接,这个waring的最简单的修正方法是,到相应类的头文件中,去掉在自定义初始化方法后面的 NS_D ...

  6. Google C++ Style Guide

    Background C++ is one of the main development languages used by many of Google's open-source project ...

  7. Google C++ 代码规范

    Google C++ Style Guide   Table of Contents Header Files Self-contained Headers The #define Guard For ...

  8. iOS 方法修饰符

     一.NS_DESIGNATED_INITIALIZER 用来修饰init方法,被修饰的方法称为designated initializer:没有被这个修饰的init方法称为convenience i ...

  9. Swift3.0P1 语法指南——构造器

    原档:https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programmi ...

随机推荐

  1. LightOJ - 1170 - Counting Perfect BST(卡特兰数)

    链接: https://vjudge.net/problem/LightOJ-1170 题意: BST is the acronym for Binary Search Tree. A BST is ...

  2. NISP二级笔记(一) 信息安全管理

    ISO27001 信息安全管理体系要求 ISO27002 信息安全控制措施(实用规则) ISO27003 信息安全管理体系实施指南 ISO27004 信息安全管理测量 ISO27005 信息安全风险管 ...

  3. linux下MySQL的启动与访问

    启动与停止 1.启动 MySQL安装完成后启动文件mysql在/etc/init.d目录下,在需要启动时运行下面命令即可. [root@test1 init.d]# /etc/init.d/mysql ...

  4. 自用 微信小程序跳小程序

    "window": { "navigationBarTextStyle": "black", "navigationBarTitl ...

  5. easyui181版本使用记录

    easyui181版本下载地址 简单java+easyui181版本demo下载 注意前端页面的ajax请求路径对应后端 如果再加强样式可使用adminLTE

  6. 如何在Processing中用鼠标获取RGB颜色数值

    要做一个抠图应用,所以随手做了个鼠标取色,代码如下: void mousePressed(){ int imgC = get(mouseX,mouseY); int R = (imgC >> ...

  7. leaflet control.layers踩的一个坑

    Control.Layers方法 该方法可以创建一个切换图层的工具, L.control.layers(baseLayers, overlayers).addTo(map); baseLayers参数 ...

  8. Java 操作Redis封装RedisTemplate工具类

    package com.example.redisdistlock.util; import org.springframework.beans.factory.annotation.Autowire ...

  9. service mesh,linkerd,sidecar,apigateway

    对于大规模部署微服务(微服务数>1000).内部服务异构程度高(交互协议/开发语言类型>5)的场景,使用service mesh是合适的.但是,可能大部分开发者面临的微服务和内部架构异构复 ...

  10. 第十二周助教工作总结——NWNU李泓毅

    助教博客链接:https://www.cnblogs.com/NWNU-LHY/ 本次作业的要求:基于原型的团队项目需求调研与分析:https://www.cnblogs.com/nwnu-daizh ...