Home > OS >  What is array subscript operator in typedef in C
What is array subscript operator in typedef in C

Time:01-18

In libgmp I see typedef __mpz_struct mpz_t[1]; what does [1] mean here?

Does it mean typedef _mpz_struct* mpz_t?

CodePudding user response:

It is not the same as a pointer.

It is defining a type named “mpz_t” which is itself an array of __mpz_structs, where the array is exactly one element long.


A lot of times, you can figure this kind of stuff out by simply removing the typedef and see what kind of variable you would be creating. In this case:

__mpz_struct mpz_t[1];

That there is an array of __mpz_structs exactly one element long, named “mpz_t”.

Prefix that typedef and now instead of declaring a variable name you are declaring a type name.

  • Related