Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-42779

Q_DECL_IMPORT and clang/gcc



    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.0.0
    • 4.8.6, 5.3.2
    • Core: Other
    • None
    • Mac OS X 10.8+, latest gcc or clang. This doesn't actually depend on this at all.


      I run into the issue described here: http://stackoverflow.com/questions/11913151/catching-derived-exceptions-types-fails-on-clang-macos-x by using Qt macros Q_DECL_EXPORT and Q_DECL_IMPORT.

      I have a dynamic library that exports some code using Q_DECL_EXPORT and a client code that uses it by using the same header with Q_DECL_IMPORT instead. This works fine on Windows, but on Mac I am unable to catch exceptions well, exactly as in the article linked above.

      I've traced this down to Q_DECL_EXPORT/IMPORT issue. The problem is that Q_DECL_EXPORT for clang is defined as _attribute_((visibility("default"))) and we need Q_DECL_IMPORT to be defined the same for the import to work, but it is defined as an empty string.

      This doesn't affect the code, unless you use -fvisibility=hidden. However, if all the symbols are visible, you don't need to specify Q_DECL_EXPORT/IMPORT at all - it just works by itself, but if the private symbols are hidden, Q_DECL_IMPORT must be the same as Q_DECL_EXPORT to enable visibility on both sides.

      So the suggestion is to define Q_DECL_IMPORT to be equal to Q_DECL_EXPORT for clang/gcc-based configurations.


        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            thiago Thiago Macieira
            ov Vitaly Ovchinnikov
            0 Vote for this issue
            2 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes