Answer the question
In order to leave comments, you need to log in
How to use one state of header file variables in several program source files?
I have a header file with variables, types, prototypes and functions.
How to use it in multiple source files of a cs program?
It turns out that the preprocessor will expand the content in each source file that defines the include for this header?
if I remove the inclusion from the second file, then I get the absence of definitions, and if I leave it, I get an error that these definitions are already in the first file.
How to properly configure the compiler so that it goes from the calls of the second file to the definitions of the inclusion substitution in the first one. Roughly speaking, these definitions should be common to both files.
Answer the question
In order to leave comments, you need to log in
I understand that the problem is with global variables?
In the header you declare the variable as extern, in one c file you define it with initialization without extern - then everything works.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question