[BUG] GuiView::zoom_max_ and GuiView::zoom_min_ are missing definitions
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Mon Jan 8 10:03:54 UTC 2024
Le 08/01/2024 à 10:52, Yexuan Xiao a écrit :
> 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_;".
>
>
Hello,
Thanks for the thorough bug report. This 2.3.x issue seems to have been
fixed in master at cd995a2b. Riki, can I backport?
JMarc
commit cd995a2bc6449c8d9d3dee494ecffcf9abdcb50f
Author: Stephan Witt <switt at lyx.org>
Date: Wed Feb 9 10:59:18 2022 +0100
Avoid static members zoom_min_ and zoom_max_
Some compilers cannot use static class members by reference.
std::min() and std::max() are passing parameters by const reference.
More information about the lyx-devel
mailing list