Skip to content

[BZ-2260] Singletons broken on g++ 4.0.x with hidden visibility; patch/workaround #2260

@jwillemsen

Description

@jwillemsen
Field Value
Bugzilla ID 2260
Reporter James Megquier
Assigned to DOC Center Support List (internal)
Product ACE
Component ACE Core
Version 5.4.7
Platform / OS x86 / Linux
Priority P3
Severity normal
Status RESOLVED
Resolution FIXED
Created 2005-10-10 17:44:56 -0500
Blocks #1991

Originally posted by James Megquier on 2005-10-10 17:44:56 -0500


Due to a GCC bug/limitation, visibility cannot be set via attributes on a
template instantiation. As a result, the ACE_EXPORT_SINGLETON_DECLARATION
ACE_EXPORT_SINGLETON_DECLARE macros are broken (they allow more than one
singleton to be created). For example, tests/Based_Pointer_Test fails because
the Based_Pointer_Repository isn't a singleton; examples/Export also fails.

The bug in question is http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17470

As a workaround, and with one important restriction, we can push/pop a
visibility pragma instead of using attributes. Since gcc supports c99, we can
use Pragma within the ACE_EXPORT_SINGLETON* macros to get the desired effect.

The important restriction is that an ACE_SINGLETON_DECLAR* macro must appear
before a typedef of the singleton in question, or GCC will simply hide the
symbol without telling you. In the few places this occurs in TAO, it is fine,
but there are a few places in ACE where the macro comes second. The patch fixes
them too.

BTW, if the Borland compiler supports _Pragma, this trick can be used to replace
the BORLANDC pragma workarounds in examples/Export/dll.h and
TAO/orbsvcs/orbsvcs/AV/AV_Core.h -- the appropriate Pragmas can be added to the
ACE_EXPORT_SINGLETON
* macros in config-borland-common.h

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions