Skip to content

Prevent some compilation warnings on MinGW#324

Merged
falkTX merged 3 commits intoDISTRHO:developfrom
lucianoiam:no-win-warn
Sep 11, 2021
Merged

Prevent some compilation warnings on MinGW#324
falkTX merged 3 commits intoDISTRHO:developfrom
lucianoiam:no-win-warn

Conversation

@lucianoiam
Copy link
Copy Markdown
Contributor

Found this working solution official-stockfish/Stockfish#1619 (comment) . There might be others...

Suppresses these warnings which are generated multiple times when compiling the examples:

Compiling DistrhoUIMain.cpp (JACK)
In file included from ../../distrho/DistrhoUIMain.cpp:17:
../../distrho/src/DistrhoUI.cpp: In function 'double DISTRHO::getDesktopScaleFactor(uintptr_t)':
../../distrho/src/DistrhoUI.cpp:62:15: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'PFN_GetProcessDpiAwareness' {aka 'long int (*)(void*, long unsigned int*)'} [-Wcast-function-type]
   62 |             = (PFN_GetProcessDpiAwareness)GetProcAddress(Shcore, "GetProcessDpiAwareness");
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../distrho/src/DistrhoUI.cpp:64:15: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'PFN_GetScaleFactorForMonitor' {aka 'long int (*)(HMONITOR__*, long unsigned int*)'} [-Wcast-function-type]
   64 |             = (PFN_GetScaleFactorForMonitor)GetProcAddress(Shcore, "GetScaleFactorForMonitor");
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@falkTX
Copy link
Copy Markdown
Contributor

falkTX commented Sep 11, 2021

I saw this before, and this has been "fixed" in a few places in DPF.
tbh I dont quite get what the warning is all about, the function is casted as needed..

in any case, this double casting doesnt look nice.
if you look into NanoVG.cpp dpf already sets up some macros to ignore these warnings.
I think that is better vs the double casting you propose here.

@lucianoiam
Copy link
Copy Markdown
Contributor Author

Right, NanoVG.cpp contains a much cleaner solution:

# if defined(__GNUC__) && (__GNUC__ >= 9)
#  pragma GCC diagnostic push
#  pragma GCC diagnostic ignored "-Wcast-function-type"
# endif

...

# if defined(__GNUC__) && (__GNUC__ >= 9)
#  pragma GCC diagnostic pop
# endif

Force-pushed to replace first version

@falkTX
Copy link
Copy Markdown
Contributor

falkTX commented Sep 11, 2021

Thanks!
If you put the macros only around the 2 GetProcAddress calls it still silences the warnings, right?
That might look a bit cleaner.

@lucianoiam
Copy link
Copy Markdown
Contributor Author

Sure, I was unsure about the style. Fixed.

@falkTX
Copy link
Copy Markdown
Contributor

falkTX commented Sep 11, 2021

Style is always a tricky thing, I sorta like the way juce does it with indented macros, but it also gets confusing when lots of them as nested together..

By the way, don't we need this same change in pugl.cpp ?

@falkTX
Copy link
Copy Markdown
Contributor

falkTX commented Sep 11, 2021

Yeah I see in https://github.com/DISTRHO/DPF/blob/main/dgl/src/pugl.cpp#L216 we need to place the same macros.

@lucianoiam
Copy link
Copy Markdown
Contributor Author

That's correct, also updated!

@falkTX
Copy link
Copy Markdown
Contributor

falkTX commented Sep 11, 2021

Cool, thanks a lot!

@falkTX falkTX merged commit 0aa4fd4 into DISTRHO:develop Sep 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants