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

后端 未结 6 1840
死守一世寂寞
死守一世寂寞 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 06:24

    Generally, I don't think it makes a huge difference whether you put them in the header or source files. However, if you need to access the members of a structure from multiple source files, it is easier to put the structure in a header file and include it from any other files where the structure is needed.

提交回复
热议问题