In the fragment below, I cannot understand why I cannot use a declaration
of “int testnum2” . . . which tells me that i do not understand “struct” (and possibly a whole lot more. I’m using an OP7200 but that shouldn’t matter . . . Any help here would be much appreciated. And border on the enlightening :)
/******************************************************
adapted from userblock_sample.c Z-World, 2002
******************************************************/
#class auto
#if _USER
#error “User block access not provided under RabbitSys.”
#endif
void main(void)
{
// a structure for our test data
struct
{
int testnum1;
long testnum2; // WHY CAN THIS NOT BE INT ???
} test_data;
// arrays for pointers to the data and data lengths
void* save_data[2];
unsigned int save_length[2];
//initialize test data
test_data.testnum1 = 60;
test_data.testnum2 = 70;
// see what we are saving
printf("test_data.testnum1 = %d
", test_data.testnum1);
printf("test_data.testnum2 = %d
", test_data.testnum2);
// put data into arrays & write to user block
save_data[0] = &test_data;
save_length[0] = sizeof(test_data);
writeUserBlockArray(0, save_data, save_length, 2);
// clear variables
test_data.testnum1 = 0;
test_data.testnum2 = 0;
// read back saved values
readUserBlockArray(save_data, save_length, 2, 0);
// what we found
printf("test_data.testnum1 = %d
", test_data.testnum1);
printf("test_data.testnum2 = %d
", test_data.testnum2);
}