Russell said:
Hi,
In setjmp.h on a linux system, there is:
typedef struct __jmp_buf_tag
{
...
} jmp_buf[1];
I could understand typedef struct { } jmp_buf, but how do i
interpret typedef struct { } jmp_buf[1] ?
Others have pointed out that the above means jmp_buf is an alias for an
array size 1 of struct __jmp_buf_tag.
I tend to lurk rather than post here, but it occurs to me that it might
be helpful to you to know that the above is the normal syntax for using
typedef to give you a name for an array.
For example, if you wanted to store 3D coordinates, you might use a type
called 'vector' that's an array of 3 doubles (not to be confused with a
computer-sciencey vector which is something else). So you'd write:
typedef double vector[3];
/* looks a bit counterintuitive I guess */
vector position = {0.0, 1.2, 3.4}, velocity={0.0, 1.0, 0.0};
position[0] = 1.5; /* etc, just use like any array */
Hope this helps.