From 2f77d3bc951743c5c7dc709a7e060c23580722fd Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Tue, 14 Dec 2021 16:16:23 +0100 Subject: [PATCH] Sketcher: GeoEnum and GeoListId constant reference outside the translation unit ================================================================================ GeoEnum static members are used in constexpr in GeoListId. Previous code worked because the static members where inside the same translation unit. This code: 1. Declares the static members to use them as constant expressions with the value 2. Definition of the static members (odr-used) shall not contain an initializer. --- src/Mod/Sketcher/App/GeoEnum.cpp | 14 +++++--------- src/Mod/Sketcher/App/GeoEnum.h | 14 +++++++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Mod/Sketcher/App/GeoEnum.cpp b/src/Mod/Sketcher/App/GeoEnum.cpp index 313c91efb1..e385ecfb75 100644 --- a/src/Mod/Sketcher/App/GeoEnum.cpp +++ b/src/Mod/Sketcher/App/GeoEnum.cpp @@ -26,15 +26,11 @@ using namespace Sketcher; -const int GeoEnum::RtPnt = -1; -const int GeoEnum::HAxis = -1; -const int GeoEnum::VAxis = -2; -const int GeoEnum::RefExt = -3; -const int GeoEnum::GeoUndef = -2000; - -constexpr const GeoElementId GeoElementId::RtPnt = GeoElementId(GeoEnum::RtPnt, PointPos::start); -constexpr const GeoElementId GeoElementId::HAxis = GeoElementId(GeoEnum::HAxis, PointPos::none); -constexpr const GeoElementId GeoElementId::VAxis = GeoElementId(GeoEnum::VAxis, PointPos::end); +const int GeoEnum::RtPnt; +const int GeoEnum::HAxis; +const int GeoEnum::VAxis; +const int GeoEnum::RefExt; +const int GeoEnum::GeoUndef; bool GeoElementId::operator==(const GeoElementId& obj) const { diff --git a/src/Mod/Sketcher/App/GeoEnum.h b/src/Mod/Sketcher/App/GeoEnum.h index 9475c9f44a..b64d11c2d2 100644 --- a/src/Mod/Sketcher/App/GeoEnum.h +++ b/src/Mod/Sketcher/App/GeoEnum.h @@ -63,11 +63,11 @@ namespace Sketcher */ struct SketcherExport GeoEnum { - static const int RtPnt; // GeoId of the Root Point - static const int HAxis; // GeoId of the Horizontal Axis - static const int VAxis; // GeoId of the Vertical Axis - static const int RefExt; // Starting GeoID of external geometry (negative geoIds starting at this index) - static const int GeoUndef; // GeoId of an undefined Geometry (uninitialised or unused GeoId) + static const int RtPnt = -1; // GeoId of the Root Point + static const int HAxis = -1; // GeoId of the Horizontal Axis + static const int VAxis = -2; // GeoId of the Vertical Axis + static const int RefExt = -3; // Starting GeoID of external geometry ( negative geoIds starting at this index) + static const int GeoUndef = -2000; // GeoId of an undefined Geometry (uninitialised or unused GeoId) }; /*! @@ -134,6 +134,10 @@ constexpr GeoElementId::GeoElementId(int geoId, PointPos pos): GeoId(geoId), Pos { } +constexpr const GeoElementId GeoElementId::RtPnt = GeoElementId(GeoEnum::RtPnt, PointPos::start); +constexpr const GeoElementId GeoElementId::HAxis = GeoElementId(GeoEnum::HAxis, PointPos::none); +constexpr const GeoElementId GeoElementId::VAxis = GeoElementId(GeoEnum::VAxis, PointPos::end); + } // namespace Sketcher namespace std