Environment
- OS: Windows (MSVC toolchain)
- Compiler: MSVC 2022
- Generator: Ninja
- CMake: (any recent version; I used CMake-based build integrating this repo as sources)
Problem 1: Non-standard C compound literal syntax used in C++ ((Vec3){...}) triggers MSVC error C4576
MSVC rejects C compound literals in C++ mode. There are multiple occurrences like:
This produces (example):
cam/hct_solver.cc:281: error: C4576: a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax
Vec3 is defined as an aggregate type:
struct Vec3 {
double a = 0.0;
double b = 0.0;
double c = 0.0;
};
Possible fix
Replace C compound literals with standard C++ aggregate initialization, e.g.
return (Vec3){r, g, b}; -> return Vec3{r, g, b};
return (Vec3){-1.0, -1.0, -1.0}; -> return Vec3{-1.0, -1.0, -1.0};
This should be portable across MSVC/Clang/GCC.
Problem 2: Narrowing conversion in ScoreOptions default member initializer triggers MSVC error C2397
In cpp/score/score.h:
struct ScoreOptions {
size_t desired = 4;
int fallback_color_argb = 0xff4285f4; // Google Blue.
bool filter = true;
};
MSVC reports:
cpp/score/score.h:39: error: C2397: conversion from 'unsigned int' to 'int' requires a narrowing conversion
Possible fix
Use an unsigned 32-bit type for ARGB (or use the existing Argb typedef if applicable), e.g.
Argb fallback_color_argb = 0xff4285f4u;
or
uint32_t fallback_color_argb = 0xff4285f4u;
(Using int for ARGB values that may exceed INT_MAX seems problematic on its own.)
Question
Is MSVC intended to be supported for the C++ implementation? If yes, I’m happy to send a PR that replaces (Vec3){...} with Vec3{...} and adjusts the fallback_color_argb type to avoid narrowing.
Environment
Problem 1: Non-standard C compound literal syntax used in C++ (
(Vec3){...}) triggers MSVC error C4576MSVC rejects C compound literals in C++ mode. There are multiple occurrences like:
return (Vec3){r, g, b};This produces (example):
cam/hct_solver.cc:281: error: C4576: a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntaxVec3is defined as an aggregate type:Possible fix
Replace C compound literals with standard C++ aggregate initialization, e.g.
return (Vec3){r, g, b};->return Vec3{r, g, b};return (Vec3){-1.0, -1.0, -1.0};->return Vec3{-1.0, -1.0, -1.0};This should be portable across MSVC/Clang/GCC.
Problem 2: Narrowing conversion in
ScoreOptionsdefault member initializer triggers MSVC error C2397In
cpp/score/score.h:MSVC reports:
cpp/score/score.h:39: error: C2397: conversion from 'unsigned int' to 'int' requires a narrowing conversionPossible fix
Use an unsigned 32-bit type for ARGB (or use the existing
Argbtypedef if applicable), e.g.Argb fallback_color_argb = 0xff4285f4u;or
uint32_t fallback_color_argb = 0xff4285f4u;(Using
intfor ARGB values that may exceedINT_MAXseems problematic on its own.)Question
Is MSVC intended to be supported for the C++ implementation? If yes, I’m happy to send a PR that replaces
(Vec3){...}withVec3{...}and adjusts thefallback_color_argbtype to avoid narrowing.