帮助上的typedef - 基本的C / C ++ [英] help on typedefs - basic c/c++

查看:103
本文介绍了帮助上的typedef - 基本的C / C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经经历了一些code和跨越,不知怎的,干扰我一个说法来了。

i have been going through some code and came across a statement that somehow disturbed me.

typedef GLfloat vec2_t[2];   

typedef GLfloat vec3_t[3];

从我的角度来看,如声明

From my perspective, a statement such as

typedef unsigned long ulong;

手段ULON​​G 均指无符号长结果
现在,可以在下面是否意味着的声明vec2_t [2] 等同于 GLfloat

typedef GLfloat vec2_t[2];

最有可能的,也许它不是本意。我想AP preciate,如果有人清除这件事对我来说。谢谢

Most likely, Probably its not the intended meaning. I would appreciate it if someone clears this up for me. Thanks

推荐答案

基本上是一个的typedef 具有完全相同的格式,作为一个正常的C声明,但它引入了另一个名字的类型,而不是该类型的变量

Basically a typedef has exactly the same format as a normal C declaration, but it introduces another name for the type instead of a variable of that type.

在你的榜样,如果没有的typedef, vec2_t 将是两个 GLfloat 秒的数组。随着的typedef这意味着 vec2_t 是该类型的新名称的两个 GLfloat 列数组。

In your example, without the typedef, vec2_t would be an array of two GLfloats. With the typedef it means the vec2_t is a new name for the type "array of two GLfloats".

typedef GLfloat vec2_t[2];

这意味着,这两个声明是等价的:

This means that these two declarations are equivalent:

vec2_t x;

GLfloat x[2];

这篇关于帮助上的typedef - 基本的C / C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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