Hi,everybody watching my topic here.
My question might be quite simple,here it comes.
I have two files ,one is named 'a.h',and the other 'a.c' and below is the code
a.h
And i key in the command "gcc a.c" ,then error message shows up which drove me carzy.
F:\UltraEditFiles\a.c:3: error: non-static declaration of 'internalUsage' follows static declaration
F:\UltraEditFiles\a.h:3: error: previous declaration of 'internalUsage' was here
F:\UltraEditFiles\a.c:3: warning: data definition has no type or storage class
If you try to have the same variable accessed in different places, put it as extern in the header and non-extern (and non-static!) into the c-file.
1 2 3 4 5
// a.h
externint internalUsage;
// a.c
int internalUsage = 100;
And finally, if you want every c-file that includes the header to have an own internal integer value seperated from all the other c-files that include the same header and want your a.c have this value to a default of 100 (whereas the other c-files that include a.h have an undefined default value), then leave your header as it is but put a "static int" before the definition in the c-file. This is a rather seldom use case... in fact, I never saw this in the wild and just invented it.