Skip to content

Commit 2fb0775

Browse files
committed
Fix build with -fsingle-precision-constant, add CI test
Signed-off-by: falkTX <falktx@falktx.com>
1 parent 95ca137 commit 2fb0775

5 files changed

Lines changed: 14 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ jobs:
4444
run: |
4545
make clean >/dev/null
4646
make -j ${{ env.JOBS }}
47+
- name: Without any warnings + -fsingle-precision-constant
48+
if: ${{ runner.os == 'Linux' }}
49+
env:
50+
CFLAGS: -Werror -fsingle-precision-constant
51+
CXXFLAGS: -Werror -fsingle-precision-constant
52+
run: |
53+
make clean >/dev/null
54+
make -j ${{ env.JOBS }}
4755
- name: Run tests
4856
if: ${{ runner.os == 'Linux' }}
4957
run: |

dgl/src/Window.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ void Window::setSize(uint width, uint height)
276276
{
277277
PuglArea area = puglGetSizeHint(pData->view, PUGL_FIXED_ASPECT);
278278

279-
if (pData->autoScaling && d_isNotEqual(scaleFactor, 1.0))
279+
if (pData->autoScaling && d_isNotEqual<double>(scaleFactor, 1.0))
280280
{
281281
area.width = d_roundToUnsignedInt(area.width * scaleFactor);
282282
area.height = d_roundToUnsignedInt(area.height * scaleFactor);
@@ -311,7 +311,7 @@ void Window::setSize(uint width, uint height)
311311
}
312312
else
313313
{
314-
if (pData->autoScaling && d_isNotEqual(scaleFactor, 1.0))
314+
if (pData->autoScaling && d_isNotEqual<double>(scaleFactor, 1.0))
315315
{
316316
width = d_roundToUnsignedInt(width * scaleFactor);
317317
height = d_roundToUnsignedInt(height * scaleFactor);
@@ -441,7 +441,7 @@ void Window::enableInternalScalingWithSize(uint baseWidth, uint baseHeight, cons
441441

442442
const double scaleFactor = pData->scaleFactor;
443443

444-
if (d_isNotEqual(scaleFactor, 1.0))
444+
if (d_isNotEqual<double>(scaleFactor, 1.0))
445445
{
446446
baseWidth = d_roundToUnsignedInt(baseWidth * scaleFactor);
447447
baseHeight = d_roundToUnsignedInt(baseHeight * scaleFactor);

dgl/src/WindowPrivateData.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static double getScaleFactor(const PuglView* const view)
6262
{
6363
// allow custom scale for testing
6464
if (const char* const scale = getenv("DPF_SCALE_FACTOR"))
65-
return std::max(1.0, std::atof(scale));
65+
return std::max<double>(1.0, std::atof(scale));
6666

6767
if (view != nullptr)
6868
return puglGetScaleFactor(view);

distrho/src/DistrhoUI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static double getDesktopScaleFactor(const uintptr_t parentWindowHandle)
9494
{
9595
// allow custom scale for testing
9696
if (const char* const scale = getenv("DPF_SCALE_FACTOR"))
97-
return std::max(1.0, std::atof(scale));
97+
return std::max<double>(1.0, std::atof(scale));
9898

9999
#if defined(DISTRHO_OS_WASM)
100100
return emscripten_get_device_pixel_ratio();
@@ -180,7 +180,7 @@ PluginWindow& UI::PrivateData::createNextWindow(UI* const ui, uint width, uint h
180180
UI::PrivateData* const uiData = s_nextPrivateData;
181181
const double scaleFactor = d_isNotZero(uiData->scaleFactor) ? uiData->scaleFactor : getDesktopScaleFactor(uiData->winId);
182182

183-
if (d_isNotEqual(scaleFactor, 1.0))
183+
if (d_isNotEqual<double>(scaleFactor, 1.0))
184184
{
185185
width *= scaleFactor;
186186
height *= scaleFactor;

examples/EmbedExternalUI/EmbedExternalExampleUI.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ class EmbedExternalExampleUI : public UI
3838

3939
setGeometryConstraints(width, height);
4040

41-
if (d_isNotEqual(scaleFactor, 1.0))
42-
setSize(width, height);
43-
4441
webview = webViewCreate("https://distrho.github.io/DPF/",
4542
getWindow().getNativeWindowHandle(),
4643
width, height, scaleFactor);

0 commit comments

Comments
 (0)