How to use a defined struct from another source file?

前端 未结 7 1977
北恋
北恋 2020-12-06 02:18

I am using Linux as my programming platform and C language as my programming language.

My problem is, I define a structure in my main source file( main.c):



        
7条回答
  •  天命终不由人
    2020-12-06 03:06

    Putting it in a header file is the normal, correct way to declare types shared between source files.

    Barring that, you can treat main.c as a header file and include it in the other file, then only compile the other file. Or you can declare the same struct in both files and leave a note to yourself to change it in both places.

提交回复
热议问题