diff options
| author | Colin Cross <ccross@android.com> | 2017-02-24 04:12:20 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2017-02-24 04:12:20 +0000 |
| commit | 477b3fc3552e8f96ee85ba4731e7d313189428e6 (patch) | |
| tree | 4063e7e86d6168971815392d112f6a0d5417fe5b /libutils/include | |
| parent | 72b689bf342e09fb71b243d66b44a789038ffb6d (diff) | |
| parent | dafd6876178c5684f1be720c4838fc149f1e8599 (diff) | |
| download | system_core-477b3fc3552e8f96ee85ba4731e7d313189428e6.tar.gz system_core-477b3fc3552e8f96ee85ba4731e7d313189428e6.tar.bz2 system_core-477b3fc3552e8f96ee85ba4731e7d313189428e6.zip | |
Merge "Fix multiton issue" am: 78b285b367 am: 6d7751a13b
am: dafd687617
Change-Id: I7e7369361dda3df0e97169c0d06ce24c57490c7d
Diffstat (limited to 'libutils/include')
| -rw-r--r-- | libutils/include/utils/Singleton.h | 18 |
1 files changed, 13 insertions, 5 deletions
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<TYPE> 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<TYPE>::sLock' required here, +// but no definition is available +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundefined-var-template" +#endif + template <typename TYPE> class ANDROID_API Singleton { @@ -56,11 +66,9 @@ private: static TYPE* sInstance; }; -template <typename TYPE> -Mutex Singleton<TYPE>::sLock; - -template <typename TYPE> -TYPE* Singleton<TYPE>::sInstance; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif /* * use ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) in your implementation file |
