extern const declaration as pointer causes hard fault in C?

65 Views Asked by At

I am working on an embedded project in IAR with C programming language. I have a const array in a file, and I'd like to access its contents from another file.

declaration in the file:

const uint8_t myArr[] ={1,2,3,4,5,6,7,8};

extern declaration in another file:

extern const uint8_t * myArr;

When I try to access it like below, it induces a Hard Fault:

uint8_t content = myArr[0];

But I can read the content smoothly If I declare the external variable with square bracket syntax like the below:

extern const uint8_t myArr[];

What's going on here?

0

There are 0 best solutions below