CodeBlocks not building my project

前端 未结 2 1428
孤城傲影
孤城傲影 2021-01-28 07:14

Every time I click the \'run\' or \'build and run\' options in CodeBlocks for Mac OSX I get this dialogue:

\"enter

相关标签:
2条回答
  • 2021-01-28 07:28

    You declare anMyArray in your header file and then include it in both your cpp files, which means your variable is getting declared twice because of header expansion.

    Move it to your main.cpp file.

    0 讨论(0)
  • 2021-01-28 07:40

    It's because you define the variable anArray in the header file. When its included in two translation units it's defined twice, giving you the duplicate symbol error.

    Just declare it in the header file

    extern int anMyArray[9];
    

    and define it in one (and only one) source file.

    0 讨论(0)
提交回复
热议问题