You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, Our team was trying to build a C++ project using tsf.h and GNU's g++ and kept getting linking errors that the functions in tsf.h were multiply defined. We traced the problem to line 59 of tsf.h:
#define TSFDEF extern
as the functions being flagged were all fully defined internally within tsf.h, not declared in tsf.h and then defined externally. We were able to fix the problem by revising line 59 as follows:
#define TSFDEF inline
Cheers,
-Joel.
The text was updated successfully, but these errors were encountered:
If there are linker errors regarding multiple definition of function bodies of tsf.h, that means that multiple .c or .cpp files have the line
#defineTSF_IMPLEMENTATION
in them.
So make sure that only one .c or .cpp file defines this macro.
Also make sure the line is not inside a header file that is included by multiple .c or .cpp files, but inside the .c or .cpp file itself.
If you absolutely cannot avoid having that define in multiple translation units across your code base (maybe a giant project with multiple libraries that are hard to control?) then you can define TSF_STATIC before including tsf.h to make the functions static.
Like this:
The result will be similar to your hack that sets the inline keyword on all API functions but less detrimental to the output binary code size. And you won't have to modify the tsf.h file itself. Which you're free to do, so if inline somehow works better for you, then that's also fine :-)
Hi, Our team was trying to build a C++ project using tsf.h and GNU's g++ and kept getting linking errors that the functions in tsf.h were multiply defined. We traced the problem to line 59 of tsf.h:
#define TSFDEF extern
as the functions being flagged were all fully defined internally within tsf.h, not declared in tsf.h and then defined externally. We were able to fix the problem by revising line 59 as follows:
#define TSFDEF inline
Cheers,
-Joel.
The text was updated successfully, but these errors were encountered: