Bug 430896

Summary: macOS: fatal error: 'endian.h' file not found
Product: [Applications] ktorrent Reporter: Yurii Kolesnykov <yurii.kolesnykov>
Component: generalAssignee: Joris Guisson <joris.guisson>
Status: REPORTED ---    
Severity: normal CC: yurii.kolesnykov
Priority: NOR    
Version First Reported In: 20.12   
Target Milestone: ---   
Platform: Other   
OS: Other   
URL: https://invent.kde.org/packaging/homebrew-kde/-/issues/18
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Yurii Kolesnykov 2020-12-28 11:43:11 UTC
SUMMARY
libktorrent doesn't build on macOS

STEPS TO REPRODUCE
1. Try to build libktorrent on macOS

OBSERVED RESULT
../src/dht/key.cpp:30:10: fatal error: 'endian.h' file not found
#include <endian.h>
         ^~~~~~~~~~
1 error generated.

Full log: https://git.io/JLyDa

EXPECTED RESULT
libktorrent should build on macOS

SOFTWARE/OS VERSIONS
macOS: 11.1 (20C69)
KDE Plasma Version: 5.20.4
KDE Frameworks Version: 5.77.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
I had tried to add workaround for macOS (#include <machine/endian.h>) as for BSD systems (patch is here: https://invent.kde.org/packaging/homebrew-kde/-/snippets/1434), but now I see:

../src/dht/key.cpp:95:29: error: use of undeclared identifier 'htobe32'

Full log: https://git.io/JLyy0

Same issue was fixed zeromq by this PR (MPL-licensed): https://github.com/zeromq/zmqpp/pull/174/files

A similar header is available in chromium/webrtc (under BSDL): https://chromium.googlesource.com/external/webrtc/+/master/rtc_base/byte_order.h