[Development] better compile-time os detection

Christian Kandeler christian.kandeler at qt.io
Tue Jul 21 10:47:40 CEST 2026


On 7/21/26 6:45 AM, EXT Tim Blechmann via Development wrote:
> working on some way of OS detection without preprocessor, there are a
> few shortcomings of QOperatingSystemVersion::OSType: most notably, it's
> impossible to dispatch linux-specific code, as there is no OSType::Linux
> (by design, as Android/OHOS are linux based as well). thiago recommended
> to discuss this on the list.

[ ... ]
> B: map OS defines to constexpr bool variables

This has the advantage of guaranteeing that everything is covered. With 
the other approaches, someone will always miss something.

Christian


More information about the Development mailing list