Should struct definitions go in .h or .c file?

后端 未结 6 1850
死守一世寂寞
死守一世寂寞 2020-12-04 05:26

I\'ve seen both full definitions of structs in headers and just declarations—is there any advantage to one method over the other?

If it makes a differen

6条回答
  •  被撕碎了的回忆
    2020-12-04 05:57

    The point is, placing it in a header file allows you to use the structure (or any other definition) from multiple source files, just by including that header file.

    But if you are sure it will only be used from one source file, then it really doesn't make any difference.

提交回复
热议问题