diff --git a/libutils/include/utils/Singleton.h b/libutils/include/utils/Singleton.h index 7cc4c18be..a989a4703 100644 --- a/libutils/include/utils/Singleton.h +++ b/libutils/include/utils/Singleton.h @@ -26,6 +26,16 @@ namespace android { // --------------------------------------------------------------------------- +// Singleton may be used in multiple libraries, only one of which should +// define the static member variables using ANDROID_SINGLETON_STATIC_INSTANCE. +// Turn off -Wundefined-var-template so other users don't get: +// instantiation of variable 'android::Singleton::sLock' required here, +// but no definition is available +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundefined-var-template" +#endif + template class ANDROID_API Singleton { @@ -56,11 +66,9 @@ private: static TYPE* sInstance; }; -template -Mutex Singleton::sLock; - -template -TYPE* Singleton::sInstance; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif /* * use ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) in your implementation file