C
christian.bongiorno
I am would love to be able to initialize a struct statically in my
class, but the compiler seems to throw a fit when I do. I have
something like
// in h file
class MyClass {
private:
static CK_INFO aStruct;
};
// in .cpp file
// yes, I know the strings must be blank padded
MyClass::aStruct = {{1,0},"christian",0,"Whatever",{2,0}};
The struct looks like this:
typedef struct CK_INFO {
CK_VERSION cryptokiVersion; /* Cryptoki interface version
number */
CK_CHAR manufacturerID[32]; /* blank padded */
CK_FLAGS flags; /* must be zero */
/* libraryDescription and libraryVersion are new for v2.0 */
CK_CHAR libraryDescription[32]; /* blank padded */
CK_VERSION libraryVersion; /* version of library */
} CK_INFO;
error C2501: 'MyClass::info' : missing storage-class or type
specifiers
error C2371: 'info' : redefinition; different basic types
I know this is propably an easy question, I am just not that familiar
with static initializing in C++
class, but the compiler seems to throw a fit when I do. I have
something like
// in h file
class MyClass {
private:
static CK_INFO aStruct;
};
// in .cpp file
// yes, I know the strings must be blank padded
MyClass::aStruct = {{1,0},"christian",0,"Whatever",{2,0}};
The struct looks like this:
typedef struct CK_INFO {
CK_VERSION cryptokiVersion; /* Cryptoki interface version
number */
CK_CHAR manufacturerID[32]; /* blank padded */
CK_FLAGS flags; /* must be zero */
/* libraryDescription and libraryVersion are new for v2.0 */
CK_CHAR libraryDescription[32]; /* blank padded */
CK_VERSION libraryVersion; /* version of library */
} CK_INFO;
error C2501: 'MyClass::info' : missing storage-class or type
specifiers
error C2371: 'info' : redefinition; different basic types
I know this is propably an easy question, I am just not that familiar
with static initializing in C++