tst-unique3.cc: Add explicit instantiation declaration for S<char>::i

Add explicit instantiation declaration of S<char>::i 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>
This commit is contained in:
H.J. Lu 2024-12-17 05:57:49 +08:00
parent 54fe008ba6
commit 080a320914

View file

@ -3,6 +3,9 @@
#include <cstdio>
#include "../dlfcn/dlfcn.h"
template<>
int S<char>::i;
int t = S<char>::i;
int