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

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

    Private structures for that file should go in the .c file, with a declaration in the .h file if they are used by any functions in the .h .

    Public structures should go in the .h file.

提交回复
热议问题