I heard that you should not define anything in the header files because of the possibility of multiple definitions, but if you have defenders, this should not happen, right? What other reasons to add external variables?
Turning on safeguards simply prohibits the multiple inclusion of a heading within a single translation unit (aka compilation unit). This does not address the issue of multiple definitions from individual translation units during communication. Therefore, you should only add declarations to header files (.h) and definitions in source files (.c).
You usually declare extern variables in header files when a variable is defined in one source file (more specifically, one translation unit) and refers to another.
extern
Source: https://habr.com/ru/post/888856/More articles:Checking WPF data? Is there anything better than IDataErrorInfo? - validationWhy doesn't Javadoc make my subclasses inherit documentation from Java classes? - javaAutomated profiling / unit testing of behavior NHibernate - profilingThe origin of the syntax try / catch / finally - programming-languages โโ| fooobar.comIs there a good alternative to factory_girl? - ruby-on-railsInherit javadoc without generating documents for an inherited source - javaCustom data structure for push, pop and finding a minimum - algorithmWhy does โbatch upgradeโ install ancient gems? - ruby-on-railsNSData from NSKeyedArchiver to NSString - objective-cHow to use tapply and keep order of values โโ- rAll Articles