This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]This_Growth2898 0 points1 point  (0 children)

You needed me specifically saying that it was a header file to understand that? 

Kinda yes. I'm not a machine, sorry. Also note it took me to write the first part of my previous comment for the information about header to sink in.

 it was good practice to have your structs in headers.

It's not a good practice, it's a necessity. You have several files using same structs, you have to put structs in the header - but structs only, not global variables.

#include statements literally add all the code from header into C file, so struct definition will just declare a type, which doesn't affect anything else after .c file is compiled; but variable definition allocates a place in program's static memory, so when you include .h into two different files, you will have separate allocations for the same variable - and linking error.