0%

How to define an array in the header file?

If an array is defined in the .h file and initialized, and the #include "xxx.h" is used to access the array in the .h file in multiple .c files , the compiler will report an error.

Even using #ifndef #define #endif;, or adding the modifier const in front of the array does not solve the problem. 💢


✔️ The solution: add the modifier static in front of the array, for example:

1
static char buf[] = {...};