hyprwm / xdg-desktop-portal-hyprland

xdg-desktop-portal backend for Hyprland
BSD 3-Clause "New" or "Revised" License
305 stars 48 forks source link

Fix build when using clang #100

Closed Rudolchr closed 1 year ago

Rudolchr commented 1 year ago

This PR is addressing the failing build with clang as described in #81.

To fix the build with clang i added the flag -Wno-address-of-temporary to allow taking temporary addresses as the already existing -fpermissive flag does for gcc.

Furthermore i made some implicit typecasts explicit that are accepted by gcc but not by clang. The macro wl_array_for_each, used in PortalManager.cpp, which comes from wayland-utils, had to be implemented inline as it does depend on an implicit typecast that clang does not accept.

If this PR is merged the project can be built with clang and gcc using GNU libstdc++. I did not test other stdlib implementations.

Rudolchr commented 1 year ago

Usually c++-style casts are better to spot. And from how far i know general coding styles it should generally be avoided to use c-style casts in c++ as they do neither show developers intent nor do they behave the same when surrounding code changes.

But after rereading about differences i guess i should preferrably use static_casts over some of these reinterpret ones for some more safety (but well these all are void* to some ptr_t so current way should be fine).

But I'll change them to what is more preferred to styling in this project. I'd think as the project is focussed on most recent c++ standard, c++-casts should be preferred.

vaxerski commented 1 year ago

I would be all for reinterpret_cast if not for the fact it's a lot of redundant characters and in the end behaves identically to C-style

Rudolchr commented 1 year ago

Replaced them with c-style casts as requested.