Skip to content

Commit

Permalink
Enable cpp20 (#1799)
Browse files Browse the repository at this point in the history
* Unable c++20

* Test code for c++ 20

* temp centos CI

* Tmp oracle CI

* Use gcc 10 in centos

* Use gcc 10 on oracle 8

* Use gcc 10 for sonar

* Format

* Fix infinite recursion in cpp20 for CString==char*

* Sonar fix

* Remove some operator overload for CString

* Revert "Remove some operator overload for CString"

This reverts commit 718083f.

* Fix windows build

* Remove test code

* Only build centOS and oracle on develop

* const corectness

Co-authored-by: Florian Omnès <[email protected]>

---------

Co-authored-by: Jason Marechal <[email protected]>
Co-authored-by: Florian Omnès <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2023
1 parent cbd55e5 commit 17391fa
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 66 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/centos7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
release:
types: [created]
push:
branches:
- develop
- branches:
- develop
schedule:
- cron: '21 2 * * *'

Expand Down Expand Up @@ -54,9 +54,14 @@ jobs:
unzip -q ortools.zip
rm ortools.zip
- name: Install gcc 10
run: |
yum install -y centos-release-scl
yum install -y devtoolset-10-gcc*
- name: Configure
run: |
source /opt/rh/devtoolset-9/enable
source /opt/rh/devtoolset-10/enable
cmake3 -B _build -S src \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
Expand All @@ -70,7 +75,7 @@ jobs:
- name: Build
run: |
source /opt/rh/devtoolset-9/enable
source /opt/rh/devtoolset-10/enable
source /opt/rh/rh-git227/enable
cmake3 --build _build --config Release -j$(nproc)
ccache -s
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/oracle8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
release:
types: [created]
push:
branches:
- develop
- branches:
- develop
schedule:
- cron: '21 2 * * *'

Expand Down Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Install libraries
run: |
dnf install -y epel-release git cmake wget rpm-build redhat-lsb-core
dnf install -y unzip libuuid-devel boost-test boost-devel gcc-toolset-9-toolchain zlib-devel
dnf install -y unzip libuuid-devel boost-test boost-devel gcc-toolset-10-toolchain zlib-devel
- name: Checkout
run: |
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Configure
run: |
source /opt/rh/gcc-toolset-9/enable
source /opt/rh/gcc-toolset-10/enable
cmake -B _build -S src \
-DCMAKE_BUILD_TYPE=release \
-DBUILD_TESTING=ON \
Expand All @@ -60,7 +60,7 @@ jobs:
- name: Build
run: |
source /opt/rh/gcc-toolset-9/enable
source /opt/rh/gcc-toolset-10/enable
cmake --build _build --config Release -j$(nproc)
- name: Run unit and end-to-end tests
Expand Down
39 changes: 21 additions & 18 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
strategy:
matrix:
os: [ubuntu-20.04]
os: [ ubuntu-20.04 ]

env:
SONAR_SERVER_URL: "https://sonarcloud.io"
Expand All @@ -37,9 +37,10 @@ jobs:

- name: Install libraries
run: |
sudo apt-get update
sudo apt-get install uuid-dev libwxgtk3.0-gtk3-dev
sudo apt-get install libboost-test-dev
sudo apt-get update
sudo apt-get install uuid-dev libwxgtk3.0-gtk3-dev
sudo apt-get install libboost-test-dev
sudo apt-get install g++-10 gcc-10
- name: Read antares-deps version
id: antares-deps-version
Expand Down Expand Up @@ -67,8 +68,8 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip3 install -r src/tests/examples/requirements.txt
python -m pip install --upgrade pip
pip3 install -r src/tests/examples/requirements.txt
- name: Init submodule
run: |
Expand All @@ -77,21 +78,23 @@ jobs:
- name: Configure
run: |
cmake -B _build -S src \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DDEPS_INSTALL_DIR=./rte-antares-deps-Debug \
-DCODE_COVERAGE=ON \
-DCMAKE_BUILD_TYPE=debug \
-DCMAKE_PREFIX_PATH="../install;${{ env.ORTOOLS_DIR }}/install" \
-DBUILD_TESTING=ON \
-DMZ_CODE_COVERAGE=ON \
-DBUILD_not_system=OFF \
-DPython3_EXECUTABLE='${{ steps.setup-python.outputs.python-path }}'
cmake -B _build -S src \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=/usr/bin/gcc-10 \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \
-DDEPS_INSTALL_DIR=./rte-antares-deps-Debug \
-DCODE_COVERAGE=ON \
-DCMAKE_BUILD_TYPE=debug \
-DCMAKE_PREFIX_PATH="../install;${{ env.ORTOOLS_DIR }}/install" \
-DBUILD_TESTING=ON \
-DMZ_CODE_COVERAGE=ON \
-DBUILD_not_system=OFF \
-DPython3_EXECUTABLE='${{ steps.setup-python.outputs.python-path }}'
- name: Build
run: |
build-wrapper-linux-x86-64 --out-dir $GITHUB_WORKSPACE/_build/output cmake --build _build --config release -j2
build-wrapper-linux-x86-64 --out-dir $GITHUB_WORKSPACE/_build/output cmake --build _build --config release -j2
- name: Test and generate coverage
continue-on-error: true
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu-system-deps-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
sudo apt-get update
sudo apt-get install uuid-dev libwxgtk3.0-gtk3-dev
sudo apt-get install libboost-test-dev
sudo apt-get install g++-10 gcc-10
- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -42,7 +43,7 @@ jobs:
- name: Configure
run: |
cmake -B _build -S src -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=release -DBUILD_TESTING=ON
cmake -B _build -S src -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=/usr/bin/gcc-10 -DCMAKE_CXX_COMPILER=/usr/bin/g++-10 -DCMAKE_BUILD_TYPE=release -DBUILD_TESTING=ON
- name: Build
run: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
sudo apt-get update
sudo apt-get install uuid-dev libwxgtk3.0-gtk3-dev
sudo apt-get install libboost-test-dev
sudo apt-get install g++-10 gcc-10
- name: Read antares-deps version
id: antares-deps-version
Expand Down Expand Up @@ -92,7 +93,9 @@ jobs:
run: |
cmake -B _build -S src \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=/usr/bin/gcc-10 \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \
-DDEPS_INSTALL_DIR=${{github.workspace}}/rte-antares-deps-Release \
-DCMAKE_BUILD_TYPE=release \
-DBUILD_TESTING=ON \
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ include(CheckCXXCompilerFlag)
include(CMakeDependentOption)
include(FetchContent)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)

if (DEFINED VCPKG_ROOT)
include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/common-settings.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Common FLAGS for all compilers
#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)

set(COMMON_GCC_FLAGS "-Wall -W -Wextra -Wfatal-errors")
if (NOT WIN32)
Expand Down
2 changes: 1 addition & 1 deletion src/ext/yuni/src/yuni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/common-settings.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules.cmake")


set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)

if(YUNI_MODULE_CORE)
# The header yuni.h must be available
Expand Down
12 changes: 6 additions & 6 deletions src/ext/yuni/src/yuni/core/string/operators.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -112,39 +112,39 @@ inline Yuni::CString<SizeT, ExpT> operator+(const Yuni::CString<SizeT, ExpT>& rh
template<uint SizeT, bool ExpT>
inline bool operator==(const char* lhs, const Yuni::CString<SizeT, ExpT>& rhs)
{
return rhs == lhs;
return rhs.equals(lhs);
}

template<uint SizeT, bool ExpT>
inline bool operator!=(const char* lhs, const Yuni::CString<SizeT, ExpT>& rhs)
{
return rhs != lhs;
return !rhs.equals(lhs);
}

template<int N, uint SizeT, bool ExpT>
inline bool operator==(const char lhs[N], const Yuni::CString<SizeT, ExpT>& rhs)
{
return rhs == lhs;
return rhs.equals(lhs);
}

template<int N, uint SizeT, bool ExpT>
inline bool operator!=(const char lhs[N], const Yuni::CString<SizeT, ExpT>& rhs)
{
return rhs != lhs;
return !rhs.equals(lhs);
}

template<class TraitsT, class AllocT, uint SizeT, bool ExpT>
inline bool operator==(const std::basic_string<char, TraitsT, AllocT>& lhs,
const Yuni::CString<SizeT, ExpT>& rhs)
{
return rhs == lhs;
return rhs.equals(lhs);
}

template<class TraitsT, class AllocT, uint SizeT, bool ExpT>
inline bool operator!=(const std::basic_string<char, TraitsT, AllocT>& lhs,
const Yuni::CString<SizeT, ExpT>& rhs)
{
return rhs != lhs;
return !rhs.equals(lhs);
}

inline bool operator==(const AnyString& mbs, Yuni::UTF8::Char c)
Expand Down
4 changes: 2 additions & 2 deletions src/tests/src/libs/antares/study/test_study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ BOOST_AUTO_TEST_SUITE(areas_operations)
BOOST_AUTO_TEST_CASE(area_add)
{
Study study;
Area* areaA = study.areaAdd("A");
const auto areaA = study.areaAdd("A");
BOOST_CHECK(areaA != nullptr);
BOOST_CHECK(areaA->name == "A");
BOOST_CHECK_EQUAL(areaA->name, "A");
BOOST_CHECK(areaA->id == "a");
}

Expand Down
5 changes: 3 additions & 2 deletions src/ui/common/component/spotlight/listbox-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ void ListboxPanel::onDraw(wxPaintEvent&)
{
auto& item = *(items[i]);
auto& group = item.group();
if (!(!group) && group != pLastGroupName)

if (!(!group) && YString(group) != pLastGroupName)
pLastGroupName = group;
}
continue;
Expand All @@ -234,7 +235,7 @@ void ListboxPanel::onDraw(wxPaintEvent&)
// Draw of the group name if the flag is enabled
if ((0 != (pFlags & Spotlight::optGroups)))
{
if (!(!group) && group != pLastGroupName)
if (!(!group) && YString(group) != pLastGroupName)
{
// Drawing the new group
bounds.x = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/simulator/application/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ void ApplWnd::title(const wxString& s)
wxString t;
if (StudyHasBeenModified())
t << wxT("* ");
t << (s.IsEmpty() ? wxT("<untitled>") : s) << wxT(" - Antares Simulator")
t << (s.IsEmpty() ? wxString(wxT("<untitled>")) : s) << wxT(" - Antares Simulator")
#ifndef NDEBUG
<< wxT(" - DEVELOPER PREVIEW")
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ wxString LayersUI::cellValue(int x, int y) const

return layerPosition != layerListEnd
? wxString::Format(wxT("%d"), pArea->ui->layerX[layerIterator->first])
: wxT("-");
: wxString(wxT("-"));

case 2:

return layerPosition != layerListEnd
? wxString::Format(wxT("%d"), pArea->ui->layerY[layerIterator->first])
: wxT("-");
: wxString(wxT("-"));
}
}
return wxEmptyString;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/simulator/windows/bindingconstraint/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void BindingConstraintInfoEditor::onSave(void*)

if (pConstraint)
{
if (not newname.empty() and pConstraint->name() != newname)
if (not newname.empty() and pConstraint->name() != Data::ConstraintName(newname))
{
if (not study.bindingConstraints.rename(pConstraint, newname))
{
Expand Down
2 changes: 1 addition & 1 deletion src/ui/simulator/windows/correlation/datasources.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public:
{
int lastLevel = 0;
int j = 0;
Yuni::CString<15, false> old;
Yuni::CString<12, false> old;
wxColour color;
wxColour colorIdentity;
const Data::Area::Vector::const_iterator end = pArray.end();
Expand Down
11 changes: 0 additions & 11 deletions src/ui/simulator/windows/hydro/dailypower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@
*/

#include "dailypower.h"
#include <wx/stattext.h>
#include "../../toolbox/components/datagrid/renderer/area/hydroprepro.h"
#include "../../toolbox/components/datagrid/renderer/area/inflowpattern.h"
#include "../../toolbox/components/datagrid/renderer/area/hydromonthlypower.h"
#include "../../toolbox/components/datagrid/renderer/area/creditmodulations.h"
#include "../../toolbox/components/button.h"
#include "../../toolbox/validator.h"
#include "../../toolbox/create.h"
#include "../../application/menus.h"
#include <wx/statline.h>

using namespace Yuni;
Expand Down Expand Up @@ -73,14 +70,6 @@ void Dailypower::createComponents()
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
pSupport->SetSizer(sizer);

const wxSize ourDefaultSize(55, wxDefaultSize.GetHeight());

enum
{
right = wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL,
left = wxLEFT | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL,
};

wxBoxSizer* sizerHigh = new wxBoxSizer(wxHORIZONTAL);

sizer->Add(sizerHigh, 2, wxALL | wxEXPAND | wxFIXED_MINSIZE);
Expand Down
14 changes: 5 additions & 9 deletions src/ui/simulator/windows/hydro/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
*/

#include "management.h"
#include <wx/stattext.h>
#include <wx/defs.h>
#include <wx/statline.h>

#include "../../toolbox/components/datagrid/renderer/area/hydroprepro.h"
#include "../../toolbox/components/datagrid/renderer/area/inflowpattern.h"
#include "../../toolbox/components/datagrid/renderer/area/hydromonthlypower.h"
#include "../../toolbox/components/button.h"
#include "../../toolbox/validator.h"
#include "../../toolbox/create.h"
#include "../../application/menus.h"
#include <wx/statline.h>

using namespace Yuni;

Expand Down Expand Up @@ -69,11 +68,8 @@ void Management::createComponents()

const wxSize ourDefaultSize(55, wxDefaultSize.GetHeight());

enum
{
right = wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL,
left = wxLEFT | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL,
};
const auto right = (wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
const auto left = (wxLEFT | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);

auto* pGrid = new wxFlexGridSizer(6, 0, 8);
sizer->Add(pGrid, 0, wxALL, 15);
Expand Down

0 comments on commit 17391fa

Please sign in to comment.