Writing the code today encountered such a link error: "Already defined in *.obj".
Error LNK2005: "void __cdeclReplacewstringvar(Class Std::basic_string<wchar_t,struct Std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::map<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std:: allocator<wchar_t> >,class std::basic_string<wchar_t,struct Std::char_traits<wchar_t>,class std: :allocator<wchar_t> >,struct std::less<class std::basic_string<wchar_t,struct std::char_traits< Wchar_t>,class std::allocator<wchar_t> > >,class std::allocator<struct std::p air<class std:: Basic_string<wchar_t,struct Std::char_traits<wchar_t>,class std::allocator<wchar_t> > const, Class Std::basic_string<wchar_t,struct Std::char_traits<wchar_t>,class std::allocator<wchar_t> > > > > Const &) "([email protected]@[email protected][email protected][email Protected]@@[email protected][email protected]@@[email protected]@[email protected][email protected][email protected][email protected]@@[email protected][email protected]@ @[email protected]@[email protected][email protected][email protected][email Protected][email protected]@@[email protected][email protected]@@[email protected]@@[email protected][email protected][email protected][email protected][email protected][email protected]@@[email protected][email protected]@@[email protected]@[email protected]@ [EMAIL&NBSP;PROTECTED]@@[EMAIL&NBSP;PROTECTED]@[EMAIL&NBSP;PROTECTED]@Z] already defined in MainFrm.obj
Replacewstringvar I wrote a public function, put in a common header file so that the project can be called from all parts, the final solution is:
To set the function to inline, simply add "inline" at the beginning of the function
inline void Replacewstringvar () { // function body }
VC + +: Error LNK2005: ... already defined in *.obj