woboq / verdigris

Qt without moc: set of macros to use Qt without needing moc
https://woboq.com/blog/verdigris-qt-without-moc.html
GNU Lesser General Public License v3.0
638 stars 58 forks source link

Fix multiple-definition linker errors caused by W_NAMESPACE macro #54

Closed strfry closed 5 years ago

strfry commented 5 years ago

C++ doesn't seem to guarantee that a constexpr global variable doesn't take runtime space, and thus might lead to linker errors when included in several compilation units.

I don't see why the variable isn't declared static here, so i propose this simple fix to make it work for us on clang.

CLAassistant commented 5 years ago

CLA assistant check
All committers have signed the CLA.

ogoffart commented 5 years ago

How do you reproduce this problem? Maybe the right fix is using inline instead?

strfry commented 5 years ago

You are right, inline is the better fix, i changed it. I haven't build a minimal example for reproducing yet, the problem appears in context of a larger project. Let me know if you decide you need a further demonstration.

ogoffart commented 5 years ago

I manually merged your commit in 2b275951fcc0301a7fd8253e40179749ea0f676f I kept static because inline is C++17 only.

Thanks for the patch.