-
Notifications
You must be signed in to change notification settings - Fork 10
Description
It is possible to compile the library using MSYS2 GNU C++.
However there is a problem on how GNU C++ and Microsoft CL handle the template instantiation.
The problem is located in WSTP .h/.c. files, in the template definitions as (for example in Get.h)
template<>
GetArray<unsigned char>::Func GetArray<unsigned char>::ArrayF = WSGetInteger8Array;
MSYS2 GNU C++ define the macro "_WIN32". This means that in "Get.c/Get.h" is active the "else" part of
#ifndef _WIN32
...
#else
template<>
GetArray<unsigned char>::Func GetArray<unsigned char>::ArrayF = WSGetInteger8Array;
...
#endif
When GNU C++ compiler includes the .h in ANOTHER project, it instantiate the template.
BUT the template is ALREADY instantiated and present in "libLLU.a", the library created compiling these source files.
This generates a linker error for "multiple instances of the same template".
The solution can be simple: it is enough to replace
#ifndef _WIN32
with
#if !defined(_WIN32) || defined(__GNUC__)
where GNUC is a unique predefined macro in GNU C/C++ compiler, in this way, the templates are instantiates inside *.c and made them available as "extern template" in the other projects.