Re: [Development] static constexpr in exported classes needs out-of-line definitions

2024-01-31 Thread Marc Mutz via Development
Thanks! Added to https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews#Variables On 18.01.24 04:35, Thiago Macieira wrote: > See http://bugreports.qt.io/browse/QTBUG-121135 for the issue and > https://codereview.qt-project.org/c/qt/qtbase/+/531251 for the solution. > > TL;DR: if you define a

Re: [Development] static constexpr in exported classes needs out-of-line definitions

2024-01-18 Thread Thiago Macieira
On Wednesday, 17 January 2024 19:35:17 PST Thiago Macieira wrote: > Alternatives: > * move to a class that is not exported >trick: add an empty base with the variable > * change to enum (if primitive) * change to an static (inline) constexpr function Then there's always a copy, because GCC

Re: [Development] static constexpr in exported classes needs out-of-line definitions

2024-01-17 Thread Thiago Macieira
On Wednesday, 17 January 2024 19:35:17 PST Thiago Macieira wrote: > This appears to be a GCC bug/shortcoming. Clang and MSVC apparently > automatically emit and export the variable for you: > https://mingw.godbolt.org/z/q4dYdosjh Reported at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113465 --

[Development] static constexpr in exported classes needs out-of-line definitions

2024-01-17 Thread Thiago Macieira
See http://bugreports.qt.io/browse/QTBUG-121135 for the issue and https://codereview.qt-project.org/c/qt/qtbase/+/531251 for the solution. TL;DR: if you define a static constexpr (which is implicitly inline) member variable in a class with export macro, you MUST add the definition of tha