用C typeof运算符 [英] typeof operator in C

查看:196
本文介绍了用C typeof运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时的typeof在C,一个真正的运营商?结果
我想因为C中没有多态性,没有什么在运行时做的。也就是说,答案的typeof在编译时是已知的。 (我想不出一个使用typeof运算的,不会在编译时已知的。)所以这似乎更编译时指令,不是一个运营商。

Is typeof in C, really an operator?
I'm thinking because there is no polymorphism in C, that there is nothing to do at run-time. That is, the answer to typeof is known at compile-time. (I can't think of a use of typeof that would not be known at compile time.) So it appears to be more of a compile-time directive, than an operator.

typeof运算是否使用任何(处理器)运行时间(GCC)?

Does typeof use any (processor) run-time (in GCC)?

推荐答案

由于的typeof 是一个编译器扩展,没有真正为它的定义,但在传统的C这将是一个运营商,如:的sizeof _Alignof 也被看作是一个运营商。

Since typeof is a compiler extension, there is not really a definition for it, but in the tradition of C it would be an operator, e.g sizeof and _Alignof are also seen as an operators.

和你错了,C具有动态类型只能在运行时确定:变量修改(VM)类型

And you are mistaken, C has dynamic types that are only determined at run time: variable modified (VM) types.

size_t n = strtoull(argv[1], 0, 0);
double A[n][n];
typeof(A) B;

只能在运行时确定。

can only be determined at run time.

这篇关于用C typeof运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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