[ros-dev] __attribute__((weak)) - in mingw

Boaz Harrosh boaz@moeg.org
Tue Feb 15 16:12:00 GMT 2005


Danny Smith wrote:

>Boaz Harrosh wrote:
>  
>
>>[Q] I'm (well ATL is) using  __attribute__((weak)) (translated from
>>__declspec( selectany) ) for instantiation of members and variables in
>>headers. I had no problem with it On GCC in Linux (gcc 3.2.2). On MinGW
>>    
>>
>
>IMAGE_COMDAT_SELECT_ANY is not quite same as PECOFF version of "weak" , but
>AFAICT is equivalent to the GCC section flag ".linkonce discard".  I don't think
>there is a way for the user to specify that for data using an attribute, but it
>could be done with asm statements.
>
>.weak directive is partially supported in current binutils CVS.
>__attribute__((weak)) is not supported by GCC-3.4.x but will be in the next
>major GCC release (4.0.0).
>
>The semantics of weak for PECOFF differ from that on Linux.See the PECOFF60
>specs (Microsoft Portable Executable and Common Object File Format
>Specification)  section on weak externals
>
>Danny
>  
>
(binutils at sources dot redhat dot com please also cc me as I'm not on 
the list)

Attached is a proof (See fooInt.h) that gcc (gcc version 3.2 (mingw 
special 20020817-1)) has support for weak symbols. Just not with the 
regular syntax.
But when templates are used duplicate symbols are merged by the linker.

What would be the assembler magic to cram into the __WEAK__ definition 
that would make this project link?

Free Life
Boaz
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Makefile.win
URL: <https://sourceware.org/pipermail/binutils/attachments/20050215/6df8a791/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cpp2.cpp
URL: <https://sourceware.org/pipermail/binutils/attachments/20050215/6df8a791/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fooInt.h
URL: <https://sourceware.org/pipermail/binutils/attachments/20050215/6df8a791/attachment.h>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: main.cpp
URL: <https://sourceware.org/pipermail/binutils/attachments/20050215/6df8a791/attachment-0002.ksh>


More information about the Binutils mailing list