What does three terms in a typedef mean?

c, c++, typedef

Solution

A bit of Googling indicates that `CK_PTR` is a macro defined in `pkcs11.h`. Follow that link to see the documentation for these definitions.

It's normally defined as:

#define CK_PTR *

but on some ancient systems it might be defined as

#define CK_PTR far *

where `far` is a mostly obsolete system-specific keyword that specifies a certain non-standard kind of pointer.

So this:

typedef CK_BYTE CK_PTR CK_BYTE_PTR;

is equivalent to this (much clearer) code:

typedef CK_BYTE *CK_BYTE_PTR;

which defined `CK_BYTE_PTR` as a pointer to a `CK_BYTE`.

The quoted definition of `CK_BYTE_PTR` occurs in the same header file.

Problem

What does it mean when there are three items in a typedef? For example: ``` typedef CK_BYTE CK_PTR CK_BYTE_PTR; ``` I know that if you just have `typedef CK_BYTE CK_PTR`; then `CK_BYTE` would just be able to be referred to as `CK_PTR`.

Original source