Most elegant way to share a C array

后端 未结 4 516
暗喜
暗喜 2021-01-18 22:01

I have to turn back to (embedded) C after some lengthy time with C++, and have the following problem:

I have a source module which is included a lot of times, let\'s

4条回答
  •  感动是毒
    2021-01-18 22:43

    Having one declaration (extern...) in each translation unit and exactly one definition is the most elegant way to do this.

    So leave the extern char important_array in the header and char important_array in one of the .c files.

提交回复
热议问题