Question

I am using Keil. I have following files 'Driver.h' and 'Driver.c'.

Driver.h

extern static int Status[5];

I know that above statement is wrong. Meaning of static changes when it is declared globally. But still, I want to declare a variable which is an array. It should be usable by another file and it should have scope in which value should not changed unless we change it.

Driver.c


int Status[5]={0x00,0x00,0x00,0x00,0x00};

The error message is shown below.

error C28:more than one storage class

Can you please help me?

Was it helpful?

Solution

Remove the static, to declare an externally located array. Then make sure that exactly one of the C files in the project actually define it, using int Status[5];.

Not sure what you mean by "it should have scope in which value should not changed unless we change it", of course it won't change unless you change it ... It will be global, visible from all modules and functions in the program.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top