typedef struct {
unsigned char data;
unsigned int intdata;
} myStruct;
extern const myStruct * const ptrConstMyStruct;
blah.c
static myStruct thisIsMyModulesData;
const myStruct * const ptrConstMyStruct = &thisIsMyModulesData;
anotherFile.c
variable = ptrConstMyStruct->data;
ptrConstMyStruct->data = variable; //compile error!
const_cast
并不是你想象的那样。你可能会想到一些未定义行为。 - Kerrek SB