You gave multiple definitions to the linker.
The symbol sth
is defined in two modules, one as an int
and one as a void
function. If the same symbol appears in more than one object file, regardless of type, the linker will throw an error if you attempt to link those together.
A symbol can only be defined in one object file. If you want to use it in others you can declare it in the other file(s) however the declaration must match the definition.
Alternately, if you want a particular symbol to only be visible in the file it was defined in and not others, you need to add the static
storage class specifier to it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…