Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does three terms in a typedef mean?

Tags:

c++

c

typedef

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.

like image 799
m3hughes Avatar asked Nov 16 '25 20:11

m3hughes


1 Answers

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.

like image 132
Keith Thompson Avatar answered Nov 19 '25 08:11

Keith Thompson