Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

__declspec(dllexport) ignored on specialized function definitions #42986

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR44016
Status NEW
Importance P enhancement
Reported by Mark Ingram (me@mark-ingram.com)
Reported on 2019-11-15 14:01:05 -0800
Last modified on 2019-11-19 12:43:14 -0800
Version 8.0
Hardware PC Windows NT
CC hans@chromium.org, htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, martin@martin.st, neeilans@live.com, paul_robinson@playstation.sony.com, richard-llvm@metafoo.co.uk, rnk@google.com, smeenai@fb.com
Fixed by commit(s)
Attachments declspec_dllexport.zip (1000 bytes, application/x-zip-compressed)
Blocks
Blocked by
See also PR20136, PR20725, PR41895
Created attachment 22817
Example

Please see the attached files. Templated class functions that are specialized,
aren't added to the list of exported functions. In the attached example, any
binary linking to this shared library will fail to find dll<int>::Func().

// dll.hpp
#ifdef DLL_EXPORT
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif

template <typename T>
struct dll
{
    DLL_API static void Func();
};

// dll.cpp
#define DLL_EXPORT
#include "dll.hpp"

#include <stdio.h>

template <>
void dll<int>::Func()
{
    printf("dll<int>::Func1\n");
}

template class DLL_API dll<int>;
Quuxplusone commented 5 years ago

Attached declspec_dllexport.zip (1000 bytes, application/x-zip-compressed): Example