mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
Use explicit instantiation declaration and definition to silence Clang error: tst-unique3.cc:6:18: error: instantiation of variable 'S<char>::i' required here, but no definition is available [-Werror,-Wundefined-var-template] 6 | int t = S<char>::i; | ^ ./tst-unique3.h:5:14: note: forward declaration of template entity is here 5 | static int i; | ^ tst-unique3.cc:6:18: note: add an explicit instantiation declaration to suppress this warning if 'S<char>::i' is explicitly instantiated in another translation unit 6 | int t = S<char>::i; | ^ Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
26 lines
534 B
C++
26 lines
534 B
C++
#include "tst-unique3.h"
|
|
|
|
#include <cstdio>
|
|
#include "../dlfcn/dlfcn.h"
|
|
|
|
extern template struct S<char>;
|
|
|
|
int t = S<char>::i;
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
std::printf ("%d %d\n", S<char>::i, t);
|
|
int result = S<char>::i++ != 1 || t != 1;
|
|
result |= in_lib ();
|
|
void *d = dlopen ("$ORIGIN/tst-unique3lib2.so", RTLD_LAZY);
|
|
int (*fp) ();
|
|
if (d == NULL || (fp = (int(*)()) dlsym (d, "in_lib2")) == NULL)
|
|
{
|
|
std::printf ("failed to get symbol in_lib2\n");
|
|
return 1;
|
|
}
|
|
result |= fp ();
|
|
dlclose (d);
|
|
return result;
|
|
}
|