警告#411:类Foo没有定义构造函数初始化如下: [英] warning #411: class foo defines no constructor to initialize the following:

查看:213
本文介绍了警告#411:类Foo没有定义构造函数初始化如下:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有C ++编译器给错误在主题行中内置了一些旧的code

I have some legacy code built with c++ compiler giving the error in the subject line

typedef struct foo {
    char const * const str;
 } Foo;

和很多在code的地方(这意味着我不能改变所有的人),在C风格的初始化使用它:

and a lot of places in the code (meaning I cannot change all of them) use it in a C style initialization:

 Foo arr[] ={
     {"death"},
     {"turture"},
     {"kill"}
  }

什么是好的解决方法除去愚蠢的警告?

What is the good workaround to remove the stupid warning?

推荐答案

如果它的工作原理,无论如何,你还不如禁用这些文件的命令行警告。

If it works anyway, you might as well disable the warning in the command line for those files.

用gcc我认为这是类似于 -wd411

With gcc I think it's something like -wd411.

不那么优雅,但是如果它的工作原理,如果code似乎是符合标准的(按顺序)没有一点出汗了呢!

Not so elegant, but if it works and if the code appears to be compliant to the standard (in this order) there's no point sweating over it!

这篇关于警告#411:类Foo没有定义构造函数初始化如下:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆