Add missing export to vsg::Exception struct#1680
Add missing export to vsg::Exception struct#1680rms7326 wants to merge 1 commit intovsg-dev:masterfrom
Conversation
If VulkanSceneGraph is compiled as a .dylib and used by another .dylib on the Mac where VulkanSceneGraph throws a vsg::Exception the client requesting the service from VulkanSceneGraph is not able to catch the vsg::Exception because the RTTI information is different. This is a known issue with clang. If the symbol is not exported for a shared library the RTTI information will not match that generated by dependent libraries for the same symbol.
|
Could there be issues under Windows with exporting a struct that is entirely defined in the header? |
|
It should be perfectly fine. |
|
This PR won't fix the bug, though, as I've run into (effectively) the same problem as this is trying to fix in the past, and it needs to be fixed by ensuring that the thing catching the exception and throwing it both export the symbol (whereas on Windows, you want the DLL to If that change is made, then as a follow-up task, we could add |
|
@AnyOldName3 this pull request isn't to fix a Windows issue but a AppleClang issue. An to be clear, by adding the @robertosfield, with regard to working with Windows, I believe your concern is address according to this MS compiler doc: |
|
I am aware that this isn't a problem with MSVC. However, this PR definitely can't do anything as the preprocessed code is identical on non-Windows platforms with and without this patch applied. The definition of #if defined(WIN32)
# if defined(vsg_EXPORTS)
# define VSG_DECLSPEC __declspec(dllexport)
# elif defined(VSG_SHARED_LIBRARY)
# define VSG_DECLSPEC __declspec(dllimport)
# else
# define VSG_DECLSPEC
# endif
#else
# define VSG_DECLSPEC
#endifso it's expanded to an empty value unless The problem isn't specific to Apple Clang, as it's exactly the same one as is discussed in GCC's visibility documentation here in the Problems with C++ exceptions (please read!) section. Symbols that are hidden aren't guaranteed to be given the same RTTI by the dynamic linker, so if anything's compiled with If this PR fixes the problem on your machine, then it's because you've done something else in your project that isn't included here, e.g. providing an alternative definition of |
Add missing export to vsg::Exception
Description
If VulkanSceneGraph is compiled as a .dylib and used by another .dylib on the Mac where VulkanSceneGraph throws a vsg::Exception the client requesting the service from VulkanSceneGraph is not able to catch the vsg::Exception because the RTTI information is different. This is a known issue with clang. If the symbol is not exported from a shared library the RTTI information will not match that generated by dependent libraries for the same symbol.
Type of change
Source change
Please delete options that are not relevant.
How Has This Been Tested?
Locally on our MacOS with arm64 architecture.
Test Configuration:
Checklist: