multiple definition of 'counter' From the linker. My header contains int counter = 0; and has an include guard. bump.c includes it. show.c includes it. There is one physical header. I'd like to know who is printing the second one behind my back.
Of course you've put a guard on the header. We are professionals. Please frame the guard and tell us which translation unit can see the one that went up next door.
Two .o files. Both compiled separately without a peep. Complaint only when the two get married. Your tone is shit but I suspect you've just told me the answer.
Im Header nur extern int counter;. Genau eine Definition in einer .c-Datei. Der Include-Guard bewacht jeden Präprozessorlauf für sich. Wer nach der Hochzeit aufräumt, steht woanders.
Then each translation unit gets its own counter. bump can increment its own copy all evening while show is still staring at zero. One extern declaration and one definition: bump once, show prints 1.
Lol at the person who privately recommended ASan. I use a sanitizer when the code is running. We're currently at the rather exciting stage of NOT HAVING A PROGRAM. The linker would like a moment of our time.