I have seen an example where someone has passed an extern struct to a function in C. Is there a good reason to do this instead of using the extern struct without passing it as a parameter? Is this solution more encapsulated?
//Test.h
struct TEST_STRUCT
{
int member;
};
extern struct TEST_STRUCT test_struct;
//Test.c
struct TEST_STRUCT test_struct = {0};
Now I can decide to pass this test_struct
to my function or to set my "member" variable in my function very comfortable like this:
test_struct.member = 10;