[BUG] GuiView::zoom_max_ and GuiView::zoom_min_ are missing definitions

Yexuan Xiao bizwen at nykz.org
Mon Jan 8 09:52:03 UTC 2024


I tried to use cmake to compile lyx, but failed because there are errors in lyx's code.
Refer to https://en.cppreference.com/w/cpp/language/static, if a const static data member or a constexpr static data member is odr-used, a definition at namespace scope is still required.
In the file src/frontends/qt4/GuiView.h line 482, zoom_max_ and zoom_min_ are declared, but not defined.
And in GuiView.cpp line 784, 4241, there is the following code: zoom = min(max(zoom, zoom_min_), zoom_max_);.
Because std::min and std::max take parameters as const T&, not T, zoom_max_ and zoom_min_ are odr-used, and thus require their definitions.
The fix is simple, in C++17 mode, declare and define zoom_max_ and zoom_min_ as "constexpr", such as "static constexpr zoom_max_ = 100;" in the class definition,
or in C++11 mode, provide their definitions in GuiView.cpp, such as "int const GuiView::zoom_max_;".

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20240108/1dc0c8b2/attachment.html>


More information about the lyx-devel mailing list