Update C++ version to 23, add new warnings and the fix them

This commit is contained in:
Alexander Bock
2025-03-01 15:49:38 +01:00
parent cd8924ed22
commit cc395ce340
28 changed files with 89 additions and 81 deletions
@@ -796,7 +796,7 @@ RenderablePointCloud::RenderablePointCloud(const ghoul::Dictionary& dictionary)
}
bool RenderablePointCloud::isReady() const {
bool isReady = _program;
bool isReady = _program != nullptr;
if (_hasLabels) {
isReady = isReady && _labels->isReady();
}
@@ -251,7 +251,7 @@ namespace {
std::optional<float> width [[codegen::greaterequal(0.f)]];
// [[codegen::verbatim(ShadingEnabledInfo.description)]]
std::optional<float> performShading;
std::optional<bool> performShading;
// [[codegen::verbatim(AmbientIntensityInfo.description)]]
std::optional<float> ambientIntensity [[codegen::greaterequal(0.f)]];
@@ -385,7 +385,7 @@ void RenderableNodeArrow::deinitializeGL() {
}
bool RenderableNodeArrow::isReady() const {
return _shaderProgram;
return _shaderProgram != nullptr;
}
void RenderableNodeArrow::updateShapeTransforms(const RenderData& data) {
@@ -195,13 +195,13 @@ RenderablePlaneImageOnline::downloadImageToMemory(const std::string& url)
{
return global::downloadManager->fetchFile(
url,
[url](const DownloadManager::MemoryFile&) {
[](const DownloadManager::MemoryFile&) {
LDEBUGC(
"ScreenSpaceImageOnline",
"Download to memory finished for screen space image"
);
},
[url](const std::string& err) {
[](const std::string& err) {
LDEBUGC(
"ScreenSpaceImageOnline",
"Download to memory failer for screen space image: " + err
@@ -143,7 +143,7 @@ namespace {
std::optional<int> sweepChunkSize;
// [[codegen::verbatim(SweepChunkSizeInfo.description)]]
std::optional<int> enableSweepChunking;
std::optional<bool> enableSweepChunking;
// [[codegen::verbatim(AccurateTrailPositionsInfo.description)]]
std::optional<int> accurateTrailPositions;
@@ -152,10 +152,10 @@ std::future<DownloadManager::MemoryFile> ScreenSpaceImageOnline::downloadImageTo
{
return global::downloadManager->fetchFile(
url,
[url](const DownloadManager::MemoryFile&) {
[](const DownloadManager::MemoryFile&) {
LDEBUG("Download to memory finished for screen space image");
},
[url](const std::string& err) {
[](const std::string& err) {
LDEBUG(std::format(
"Download to memory failed for screen space image: {}", err
));
+1 -1
View File
@@ -142,7 +142,7 @@ double GeodeticPatch::edgeLatitudeNearestEquator() const {
return _center.lat + _halfSize.lat * (isNorthern() ? -1.0 : 1.0);
}
double GeodeticPatch::isNorthern() const {
bool GeodeticPatch::isNorthern() const {
return _center.lat > 0.0;
}
+1 -1
View File
@@ -53,7 +53,7 @@ public:
/**
* Returns `true` if the center above the equator.
*/
double isNorthern() const;
bool isNorthern() const;
Geodetic2 corner(Quad q) const;
@@ -177,9 +177,9 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
childSplitType
);
BrickSelection childSelection = bs.splitSpatially(
i % 2,
(i/2) % 2,
i/4,
i % 2 != 0,
(i/2) % 2 != 0,
i/4 != 0,
childBrickIndex,
childSplitType,
childSplitPoints
@@ -59,7 +59,7 @@ void ShenBrickSelector::traverseOT(int timestep, unsigned int brickIndex,
int numTimeSteps = _tsp->header().numTimesteps;
for (unsigned int i = 0; i < 8; i++) {
unsigned int child = firstChild + i;
BrickCover cover = coveredBricks.split(i % 2, (i/2) % 2, (i/4));
BrickCover cover = coveredBricks.split(i % 2 != 0, (i/2) % 2 != 0, (i/4) != 0);
selectBricks(timestep, child, child, 0, numTimeSteps, cover, bricks);
}
}
@@ -175,9 +175,9 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
BrickSelection::SplitType childSplitType;
float childSplitPoints = splitPoints(childBrickIndex, childSplitType);
BrickSelection childSelection = bs.splitSpatially(
i % 2,
(i / 2) % 2, // abock: this is always 0?
i / 4,
i % 2 != 0,
(i / 2) % 2 != 0, // abock: this is always 0?
i / 4 != 0,
childBrickIndex,
childSplitType,
childSplitPoints
@@ -187,9 +187,9 @@ void TfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks) {
float childSplitPoints = splitPoints(childBrickIndex, childSplitType);
//std::cout << "Splitting spatially" << std::endl;
BrickSelection childSelection = bs.splitSpatially(
i % 2,
(i / 2) % 2, // abock: isn't this always 0?
i / 4,
i % 2 != 0,
(i / 2) % 2 != 0, // abock: isn't this always 0?
i / 4 != 0,
childBrickIndex,
childSplitType,
childSplitPoints
+1 -1
View File
@@ -178,7 +178,7 @@ void Browser::update() {
}
bool Browser::isReady() const {
return _texture.get();
return _texture != nullptr;
}
// Updates the browser size to match the size of the texture
+1 -1
View File
@@ -51,7 +51,7 @@ namespace {
bool hasAttribute(const tinyxml2::XMLElement* element, std::string_view name) {
const std::string n = std::string(name);
return element->FindAttribute(n.c_str());
return element->FindAttribute(n.c_str()) != nullptr;
}
std::string attribute(const tinyxml2::XMLElement* element, std::string_view name) {
@@ -290,7 +290,7 @@ void RenderableEclipseCone::deinitializeGL() {
}
bool RenderableEclipseCone::isReady() const {
return _shader;
return _shader != nullptr;
}
void RenderableEclipseCone::render(const RenderData& data, RendererTasks&) {
@@ -257,7 +257,7 @@ void RenderableShadowCylinder::deinitializeGL() {
}
bool RenderableShadowCylinder::isReady() const {
return _shader;
return _shader != nullptr;
}
void RenderableShadowCylinder::render(const RenderData& data, RendererTasks&) {
-16
View File
@@ -40,22 +40,6 @@ namespace {
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo SelectionInfo = {
"SpoutSelection",
"Spout Selection",
"This property displays all available Spout sender on the system. If one them is "
"selected, its value is stored in the 'SpoutName' property, overwriting its "
"previous value.",
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo UpdateInfo = {
"UpdateSelection",
"Update Selection",
"If this property is trigged, the 'SpoutSelection' options will be refreshed.",
openspace::properties::Property::Visibility::AdvancedUser
};
struct [[codegen::Dictionary(ScreenSpaceSpout)]] Parameters {
// [[codegen::verbatim(NameInfo.description)]]
std::optional<std::string> spoutName;
+1 -1
View File
@@ -402,7 +402,7 @@ HttpSynchronization::trySyncFromUrl(std::string url) {
originalName.replace_extension().string();
struct zip_t* z = zip_open(source.c_str(), 0, 'r');
const bool is64 = zip_is64(z);
const bool is64 = zip_is64(z) == 1;
zip_close(z);
if (is64) {
+10 -1
View File
@@ -90,7 +90,9 @@ add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper SYSTEM)
mark_as_advanced(CEF_DEBUG_INFO_FLAG USE_ATL USE_OFFICIAL_BUILD_SANDBOX USE_SANDBOX)
if (UNIX)
if (WIN32)
target_compile_options(libcef_dll_wrapper PRIVATE "/W0")
elseif (UNIX)
target_compile_options(libcef_dll_wrapper PRIVATE "-w")
endif ()
@@ -207,6 +209,13 @@ else()
message(STATUS "Setting up WebBrowser CEF helper executable: ${CEF_HELPER_TARGET}")
set_openspace_cef_target_out_dir()
add_executable(${CEF_HELPER_TARGET} ${WEBBROWSER_HELPER_SOURCES})
if (WIN32)
target_compile_options(${CEF_HELPER_TARGET} PRIVATE "/W0")
elseif (UNIX)
target_compile_options(${CEF_HELPER_TARGET} PRIVATE "-w")
endif ()
set_executable_target_properties(${CEF_HELPER_TARGET})
add_dependencies(${CEF_HELPER_TARGET} libcef_dll_wrapper)
# Logical target used to link the libcef library.
@@ -124,6 +124,7 @@ function(run_cef_windows_config CEF_TARGET CEF_ROOT MODULE_PATH)
# Executable target.
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_TARGET} PUBLIC libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
include_directories(${CEF_ROOT})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper "${CEF_HELPER_TARGET}")
@@ -25,33 +25,9 @@
#ifndef __OPENSPACE_MODULE_WEBBROWSER___WEBBROWSERAPP___H__
#define __OPENSPACE_MODULE_WEBBROWSER___WEBBROWSERAPP___H__
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable : 4100)
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wshadow-field"
#pragma clang diagnostic ignored "-Wcomma"
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#include <include/cef_app.h>
#include <include/wrapper/cef_helpers.h>
#ifdef _MSC_VER
#pragma warning (pop)
#elif defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic pop
#endif
namespace openspace {
/**
+1 -1
View File
@@ -289,7 +289,7 @@ bool WebRenderHandler::hasContent(int x, int y) {
}
int index = x + _browserBufferSize.x * (_browserBufferSize.y - y - 1);
index = glm::clamp(index, 0, static_cast<int>(_browserBuffer.size() - 1));
return _browserBuffer[index].a;
return _browserBuffer[index].a != 0;
}
}
+1 -7
View File
@@ -1036,13 +1036,7 @@ void OpenSpaceEngine::loadFonts() {
}
LDEBUG(std::format("Registering font '{}' with key '{}'", fontName, key));
const bool success = global::fontManager->registerFontPath(key, fontName);
if (!success) {
LERROR(std::format(
"Error registering font '{}' with key '{}'", fontName, key
));
}
global::fontManager->registerFontPath(key, fontName);
}
try {
+1 -1
View File
@@ -242,7 +242,7 @@ namespace {
}
struct zip_t* z = zip_open(source.c_str(), 0, 'r');
const bool is64 = zip_is64(z);
const bool is64 = zip_is64(z) == 1;
zip_close(z);
if (is64) {
+2 -2
View File
@@ -485,7 +485,7 @@ std::vector<std::pair<int, std::string>> SpiceManager::spiceBodies(
}
bool SpiceManager::hasValue(int naifId, const std::string& item) const {
return bodfnd_c(naifId, item.c_str());
return bodfnd_c(naifId, item.c_str()) == SPICETRUE;
}
bool SpiceManager::hasValue(const std::string& body, const std::string& item) const {
@@ -515,7 +515,7 @@ bool SpiceManager::hasNaifId(const std::string& body) const {
SpiceInt id = 0;
bods2c_c(body.c_str(), &id, &success);
reset_c();
return success;
return success == SPICETRUE;
}
int SpiceManager::frameId(const std::string& frame) const {
@@ -23,16 +23,60 @@
##########################################################################################
function (set_openspace_compile_settings target)
target_compile_features(${target} PUBLIC cxx_std_20)
target_compile_features(${target} PUBLIC cxx_std_23)
set(MSVC_WARNINGS
"/MP" # Multi-threading support
"/W4" # Highest warning level
"/w44062" # missing case label
"/w44165" # 'HRESULT' is being converted to 'bool'
"/w44242" # conversion from 'type1' to 'type2', possible loss of data
"/w44254" # conversion from 'type1' to 'type2', possible loss of data
"/w44263" # member function does not override any base class virtual member function
"/w44265" # class has virtual functions, but destructor is not virtual
"/w44287" # unsigned/negative constant mismatch
"/w44289" # using for-loop variable outside of loop
"/w44296" # expression is always true/false
"/w44437" # dynamic_cast could fail in some contexts
"/w44545" # expression before comma evaluates to a function missing an argument list
"/w44547" # operator before comma has no effect
"/w44548" # operator before comma has no effect
"/w44549" # operator before comma has no effect
"/w44555" # expression has no effect; expected expression with side-effect
"/w44574" # 'identifier' is defined to be '0': did you mean to use '#if identifier'?
"/w44619" # #pragma warning: there is no warning number 'number'
"/w44643" # Forward declaring 'identifier' in namespace std is not permitted
"/w44800" # Implicit conversion from 'type' to bool. Possible information loss
"/w44822" # local class member function does not have a body
"/w44841" # non-standard extension used: compound member designator used in offsetof
"/w44842" # the result of 'offsetof' applied to a type using multiple inheritance is
# not guaranteed to be consistent between compiler releases
"/w44946" # reinterpret_cast used between related classes: 'class1' and 'class2'
"/w44986" # exception specification does not match previous declaration
"/w44987" # nonstandard extension used: 'throw (...)'
"/w45022" # multiple move constructors specified
"/w45023" # multiple move assignment operators specified
"/w45031" # #pragma warning(pop): likely mismatch, popping warning state pushed in
# different file
"/w45032" # detected #pragma warning(push) with no #pragma warning(pop)
"/w45038" # data member 'member1' will be initialized after data member 'member2'
"/w45041" # out-of-line definition for constexpr data is deprecated
"/w45042" # function declarations at block scope cannot be specified 'inline'
"/w45204" # virtual class has non-virtual trivial destructor
"/w45233" # explicit lambda capture 'identifier' is not used
"/w45340" # attribute is ignored in this syntactic position
"/w45243" # using incomplete class 'class-name' can cause potential one definition
# rule violation due to ABI limitation
"/w45245" # unreferenced function with internal linkage has been removed
"/w45249" # 'bitfield' of type 'enumeration_name' has named enumerators with values
# that cannot be represented in the given bit field width of
# 'bitfield_width'.
"/w45258" # explicit capture of 'symbol' is not required for this use
"/w45259" # explicit specialization requires 'template <>'
"/w45262" # implicit fall-through occurs here
"/w45263" # calling 'std::move' on a temporary object prevents copy elision
"/w45264" # 'const' variable is not used
"/w45266" # 'const' qualifier on return type has no effect
"/wd4127" # conditional expression is constant [raised by: websocketpp]
"/wd4201" # nonstandard extension used : nameless struct/union [raised by: GLM]
"/wd5030" # attribute 'attribute' is not recognized [raised by: codegen]