This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __declspec(selectany)
- From: Dan Kegel <dank at kegel dot com>
- To: Fergus Henderson <fjh at cs dot mu dot OZ dot AU>
- Cc: boaz at hishome dot net, wine-devel at winehq dot com, GCC Mailing List <gcc at gcc dot gnu dot org>
- Date: Tue, 05 Aug 2003 21:12:33 -0700
- Subject: Re: __declspec(selectany)
- References: <3F302784.80903@kegel.com> <20030806032610.GA24995@ceres.cs.mu.oz.au>
Fergus Henderson wrote:
On 05-Aug-2003, Dan Kegel <dank@kegel.com> wrote:
Part of the solution might be to apply the following patch to the
gcc-3.3 source tree:
Rather than patching gcc, an easier solution would be to put the
corresponding #defines for _cdecl etc. in a header file called say
"ms_extensions.h", and then compile with "gcc -include ms_extensions.h ..."
so that these #defines get automatically included in every compilation unit.
Silly me. For some reason I thought the builtin declarations were
magic. Here's a little demo that might show the basic idea.
Does this do what you needed, Boaz?
- Dan
$ gcc -include msextensions.h foo.c bar.c
$ ./a.out
Value of x is 7
$ gcc -include msextensions.h bar.c foo.c
$ ./a.out
Value of x is 1
::::::::::::::
msextensions.h
::::::::::::::
#define __declspec(x) __attribute__((x))
#define selectany weak
::::::::::::::
foo.c
::::::::::::::
int __declspec(selectany) x = 7;
::::::::::::::
bar.c
::::::::::::::
#include <stdio.h>
int __declspec(selectany) x = 1;
int main()
{
printf("Value of x is %d\n", x);
}
--
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045