function already defined in .obj

后端 未结 1 1857
夕颜
夕颜 2021-02-20 14:44

From what I understand, this error is caused by not properly using header guards when you have multiple files including the same file. In my case, this is the include tree that

相关标签:
1条回答
  • 2021-02-20 15:14

    It seems you are trying to define a variable in a header file. If that header file is included in several source file it will be define in each source file thereby giving you the error.

    Instead declare it as extern and then define in one of your source files.

    So in the header file:

    extern ObjectType Object;
    

    And in a source file:

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