delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Message-ID: | <3FB7C911.5030203@jon-foster.co.uk> |
Date: | Sun, 16 Nov 2003 18:59:29 +0000 |
From: | Jon Foster <jon AT jon-foster DOT co DOT uk> |
User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 |
X-Accept-Language: | en-gb, en |
MIME-Version: | 1.0 |
To: | "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com> |
Subject: | Exporting const variables from DLLs (GCC bug?) |
X-Virus-Scanned: | by amavisd-new at eclipse.net.uk |
Hi, Given this source code: > extern const int meaning_of_life __declspec(dllexport); > const int meaning_of_life __declspec(dllexport) = 42; GCC complains: > $ c++ -g -O2 -c test.cxx -o test.o > test.cxx:2: error: external linkage required for symbol 'const int > meaning_of_life' because of 'dllexport' attribute. However, it compiles successfully with the "const" qualifier removed: > extern int meaning_of_life __declspec(dllexport); > int meaning_of_life __declspec(dllexport) = 42; Why does adding the "const" qualifier change this? Is this a known limitation of DLLs? If so, the error message is a little confusing. If not, then this is a GCC bug. Removing the explicit "extern" line has no effect in either case. My Cygwin installation was updated recently - I'm using the standard Cygwin GCC 3.3.1-3 package: > $ c++ --version > c++ (GCC) 3.3.1 (cygming special) If you want any more info, just ask. Incidentally, this bug affects src/sid/component/ in the Cygwin CVS tree. I'd prepared this minimal test case before I realized that this subdirectory isn't needed to build the Cygwin DLL. (Doh! CVS doing unexpected things strikes again). Kind regards, Jon Foster -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |