Unfortunately, PKCS #11 is not completely platform-independent. In order for your application to work, you'll have to provide some platform-specific definitions.
For this example, we'll just place them in the main header file. If your application has to be portable, you could provide separate header files and choose the correct one through a configure script.
In this example, we chose for Linux. The specific settings for other platforms can be found in chapter 8 of the specification.
Let's create a header file pkcs11_linux.h:
#define CK_PTR * #define CK_DEFINE_FUNCTION(returnType, name) \ returnType name #define CK_DECLARE_FUNCTION(returnType, name) \ returnType name #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \ returnType (* name) #define CK_CALLBACK_FUNCTION(returnType, name) \ returnType (* name) #ifndef NULL_PTR #define NULL_PTR 0 #endif #include "pkcs11.h" #include <stdio.h> #include <stdlib.h>