From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12774 invoked by alias); 2 Sep 2005 00:17:06 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 12702 invoked by uid 48); 2 Sep 2005 00:16:58 -0000 Date: Fri, 02 Sep 2005 00:17:00 -0000 Message-ID: <20050902001658.12700.qmail@sourceware.org> From: "jmegq at radiance dot com" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040913213750.17470.austern@apple.com> References: <20040913213750.17470.austern@apple.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/17470] Visibility attribute ignored for explicit template instantiation X-Bugzilla-Reason: CC X-SW-Source: 2005-09/txt/msg00160.txt.bz2 List-Id: ------- Additional Comments From jmegq at radiance dot com 2005-09-02 00:16 ------- Regarding macros -- I just found out about the _Pragma directive from C99, so at least you can do something like this (paraphrasing some ACE code): #define EXPORT_SINGLETON_DECLARE (SINGLETON_TYPE, CLASS, LOCK) \ _Pragma ("GCC visibility push(default)") \ template class SINGLETON_TYPE ; \ _Pragma ("GCC visibility pop") #define IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) extern template class SINGLETON_TYPE ; Then define SINGLETON_DECLARE to depending on whether you're building the lib or not. A possible issue with this is that it must come before, say, a typedef of the template type. The example below works on VS but not g++ (not that VS matters, but I'm using code that does this): typedef Singleton_T FOO_SINGLETON; SINGLETON_DECLARE(Singleton_T, Foo, Mutex) Instead, the SINGLETON_DECLARE needs to come before the typedef or it will get hidden visibility on g++. I'm curious as to why the typedef causes the symbols to get hidden visibility -- is that in spec, or is a bug? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17470