Here’s my problem:
I have a big main.c file containing 40 or so “global” structures in my program (they are declared at the begining on the files), I also have several functions in my main.c file that I are able to directly read and write into these structures since they are global.
Now I’m trying to move several function of my original main.c file into another .c file that would contain only the functions related to a specific part of my program. But of course I cannot directly access the main.c global variables from my new .c file.
Is there a way around this?
I’d like to avoid passing every structure by pointer as this would get horrible function prototypes.
thanks
Here’s my problem: I have a big main.c file containing 40 or so global
Share
Move the global structure definitions into a header (.h) file and just
#includeyour header in each c file that needs to access those structures. Any global variables can be declaredexternand then defined in your main.c.Global.h
main.c
other.h
other.c