the errors :
error LNK1169: one or more multiply defined symbols found
error LNK2005: "void __cdecl sleep(unsigned int)" (?sleep@@YAXI@Z) already defined in stdafx.obj
The microsoft site said:
The /FORCE or /FORCE:MULTIPLE option overrides this error.
The problem is that the sleep function is defined multiple times, once for each translation unit that includes the header. To solve this you can make the sleep function inline (because inline functions follow different rules) or move the definition of the function to a source file.
If i move the definitions to the source file, the following errors occur :
error C2084: function 'void sleep(unsigned int)' already has a body
error C3861: 'sleep': identifier not found
Making the function inline works,but what if in the future i dont want the function to be inline ?How can i solve this problem ? Is there a more elegant way to write this piece of code ,to make it compile on more than just windows .