为什么指定初始化以g没有实现++ [英] Why are designated initializers not implemented in g++

查看:103
本文介绍了为什么指定初始化以g没有实现++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有为什么的指定初始化的支持没有被添加至G任何具体的原因++?是C99的标准来晚和g ++开发的原因较早和较晚的人不关心这个问题,或者出现在C的语法实现指定初始化++的一些固有的困难?

Is there any specific reason why has support for designated initializers not been added to g++? Is the reason that C99 standards came late and g++ was developed earlier and later people didn't care about this issue, or there is some inherent difficulty in implementing designated initializers in the grammar of C++?

推荐答案

正如我在评论指出,G ++不支持C99标准指定initialisers,但它支持GNU扩展到C90,它允许指定initialisers。所以这不起作用:

As I noted in a comment, G++ doesn't support C99 standard designated initialisers, but it does support the GNU extension to C90 which allows designated initialisers. So this doesn't work:

union value_t {
    char * v_cp;
    float v_f;
};
union value_t my_val = { .v_f = 3.5f };

但这:

union value_t my_val = { v_f: 3.5f };

这似乎是C和C ++标准委员会之间的协调不好的交互(有没有特别好的理由C ++不支持C99的语法,他们只是还没有考虑过它),GCC政治( C ++不应该支持C99语法,只是因为它是在C99,但它应该支持实现了完全一样的东西GNU扩展语法,因为这是一个可以应用到任何语言GNU扩展)。

This seems to be a bad interaction of co-ordination between the C and C++ standards committees (there is no particularly good reason why C++ doesn't support the C99 syntax, they just haven't considered it) and GCC politics (C++ shouldn't support C99 syntax just because it's in C99, but it should support GNU extension syntax that achieves exactly the same thing because that's a GNU extension that can be applied to either language).

这篇关于为什么指定初始化以g没有实现++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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