[ 
http://issues.apache.org/jira/browse/XERCESC-1550?page=comments#action_12436513 
] 
            
Tommi Vainikainen commented on XERCESC-1550:
--------------------------------------------

Here is a patch for this problem. This problem also appears if you try to 
compile your own software which links to Xerces with gcc -fvisibility=hidden 
and use dynamic_cast for DOM types.

 util/Compilers/GCCDefs.hpp
--- util/Compilers/GCCDefs.hpp.orig     2006-09-21 15:21:17.000000000 +0300
+++ util/Compilers/GCCDefs.hpp  2006-09-21 15:22:39.000000000 +0300
@@ -37,9 +37,14 @@
 #define PLATFORM_EXPORT __declspec(dllexport)
 #define PLATFORM_IMPORT __declspec(dllimport)
 #else
+#if __GNUC__ >= 4
+#define PLATFORM_EXPORT __attribute__ ((visibility("default")))
+#define PLATFORM_IMPORT __attribute__ ((visibility("default")))
+#else
 #define PLATFORM_EXPORT
 #define PLATFORM_IMPORT
 #endif
+#endif

 // ---------------------------------------------------------------------------
 //  Indicate that we do not support native bools



> symbols visibility + inline virtual desctructors => dynamic_cast<DOMElement> 
> failure in user code
> -------------------------------------------------------------------------------------------------
>
>                 Key: XERCESC-1550
>                 URL: http://issues.apache.org/jira/browse/XERCESC-1550
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Build
>    Affects Versions: 2.7.0
>         Environment: OSX GCC 4.0
>            Reporter: Miklos Fazekas
>
> We have a code like this:
> XMLTest.cpp:
>          DOMNodeList* nodes = doc->getElementsByTagName(L("TABLE"));
>       if ( int i=nodes->getLength() == 1 )
>       {
>               DOMNode* att_node = nodes->item(0);
>               DOMElement* att_element = dynamic_cast<DOMElement*>(att_node);
>                    printf ("Element:%d\n", att_element);
>       } 
> On OSX when we use symbols visibility attrbiutes, the dynamic_cast returns 0.
> The issue seems to be the following:
> 1. There is two RTTI entries generated for the class. [According to C++ the 
> RTTI is generated at the place of the implementation of first virtual 
> function.]
> 2. One RTTI entry is marked with visibility("hidden") and found in usercode. 
> The other one is marked with visibility("default").
> 3. It seems that if there's an RTTI marked as "hidden" the dynamic_cast can't 
> work. Quote from http://gcc.gnu.org/wiki/Visibility :
> " Symbol visibility is "default" by default but if it encounters just one 
> definition with it hidden - just one - that typeinfo symbol becomes 
> permanently hidden (remember the C++ standard's ODR - one definition rule).  
> " 
> class CDOM_EXPORT DOMElement: public DOMNode {
> public:
>     ...
>     virtual ~DOMElement() {};
>     ...
> }
> Possible fixes:
> a.) Implement the destructor in a C++ file, compiled into xerces c++. This 
> would avoid multiple RTTI .
> b.) set CDOM_EXPORT to visibility("default") even when it's used from the 
> user code.
> We choose a.) as it seems to be a nicer solution. 
> [By the way i do not see why symbols visibility of GCC should work that 
> crappy with dynamic_cast, but there's not too much i could do there.]
> References:
> http://gcc.gnu.org/wiki/Visibility

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to