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;
Means that ulong is taken to mean unsigned long
Now, can the statement below mean that vec2_t[2] is equivalent to GLfloat??
typedef GLfloat vec2_t[2];
Most likely, Probably its not the intended meaning. I would appreciate it if someone clears this up for me. Thanks
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.
In your example, without the typedef, vec2_t
would be an array of two GLfloat
s. With the typedef it means the vec2_t
is a new name for the type "array of two GLfloat
s".
typedef GLfloat vec2_t[2];
This means that these two declarations are equivalent:
vec2_t x;
GLfloat x[2];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With