4 ms·
There was still the 'moc' magic in the traditional Qt. But the interesting question is can something like Qt be fully build in modern c++ without need for suc
by billfruit 3y ago
There was still the 'moc' magic in the traditional Qt.
But the interesting question is can something like Qt be fully build in modern c++ without need for such magic?
- righthand 3y agoYes that’s what I’m saying you can build your software without this magic (moc, uic, qml) but it’s not clear that’s what is happening in the documentation for it. You simply just strip out the register for it in the proper files and then delete the xml or qml files. A lot of this stuff gets further promoted in things like Qt Creator which relies on building these kind of meta definition files. Moc is less of a problem IMO because it’s more related to C++ macros which at least is a language feature.
- saidinesh5 3y agoThere were a couple of attempts in that direction, but i haven't really seen them used in any production codebase. https://woboq.com/blog/verdigris-qt-without-moc.html https://woboq.com/blog/verdigris-qt-without-moc.html
- jcelerier 3y agohttps://ossia.io https://ossia.io uses verdigris pretty much exclusively. Worse syntax but lots of advantages compared to moc.
- jenadine 3y agoWhat advantages?
- jcelerier 3y ago- Ability to use latest standards without issues - for a long time moc's c++ parser choked on headers containing too recent C++ features, breaking the build. For instance I remember noexcept and [[attributes]] being quite problematic a few years ago. Verdigris in contrast is just macros with c++17/20 code so it works and keeps working with newer standards. - moc integration in build systems would also not work well, e.g. for a long time there were issues in cmake's automoc if two files had the same name in different folder of the same project.. gets kinda complicated when you have projects with multiple thousands of source files. - I observed decreased build times after the switch - It's just a couple headers, very easy to experiment with changes and improvements
- pjmlp 3y agoNot until reflection comes to be. Maybe with concepts + if constexpr + traits, if one is willing to open the druids metaprogramming book.
- vintagedave 3y agoYou need other magic. C++Builder does it via compiler extensions for properties/events instead of something like moc, so at least it’s a closer-to-code compilation. One day it’ll be in C++ natively. PME (property, method, event) was proposed to the committee in 2002. Modern C++ uses a different approach, but as is common with current additions, it can be argued is far more verbose and clumsy. https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1384.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n13... Then of course Microsoft has their property (subset) syntax, Unreal Engine has their macros and build system, Qt has reflection and C++Builder the same via extended RTTI… everyone who needs this, whether it’s Qt, MS, Epic, Embarcadero, etc reinvents their own mostly overlapping wheels. And still in 2023 a solved problem has not made it into the standard. The most powerful in terms of width of features is C++Builder and I often wonder what would happen if Epic adopted a similar or the same pattern instead of using macros and preprocessing. Probably C++ would be forced to either split or adopt support for the features multiple companies need.