Fergus Henderson wrote:
On 05-Aug-2003, Dan Kegel <[EMAIL PROTECTED]> 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




Reply via email to