~emersion/basu#14: 
clang -Wpedantic enum int range

Apparently clang doesn't like 64-bit enum values now:

/usr/local/include/basu/sd-bus.h:88:9: error: ISO C restricts enumerator values to range of 'int' (2147483648 is too large) [-Werror,-Wpedantic]
        SD_BUS_CREDS_UNIQUE_NAME        = 1ULL << 31,
        ^                                 ~~~~~~~~~~
/usr/local/include/basu/sd-bus.h:89:9: error: ISO C restricts enumerator values to range of 'int' (4294967296 is too large) [-Werror,-Wpedantic]
        SD_BUS_CREDS_WELL_KNOWN_NAMES   = 1ULL << 32,
        ^                                 ~~~~~~~~~~
…

and in another file

/usr/local/include/basu/sd-bus-vtable.h:46:9: error: ISO C restricts enumerator values to range of 'int' (72056494526300160 is too large) [-Werror,-Wpedantic]
        _SD_BUS_VTABLE_CAPABILITY_MASK             = 0xFFFFULL << 40
        ^                                            ~~~~~~~~~~~~~~~
Status
REPORTED
Submitter
github.com:unrelentingtech (unverified)
Assigned to
No-one
Submitted
2 years ago
Updated
2 years ago
Labels
No labels applied.

github.com:kennylevinsen (unverified) 2 years ago · edit

Hmm, this is part of the API. I think we're stuck with an enum. We could try to remove values and compress it to fit in a 32-bit range, but that's not great either...

github.com:emersion (unverified) 2 years ago · edit

Has upstream systemd done something about this?

github.com:kennylevinsen (unverified) 2 years ago · edit

Their enum is identical in master: https://github.com/systemd/systemd/blob/6c41cf445912c12e14b1e94414a0fce1fa060ac2/src/systemd/sd-bus.h#L58

I don't think they build with -Wpedantic though. Neither do we for that matter.

github.com:unrelentingtech (unverified) 2 years ago · edit

I guess one "solution" would be #pramga GCC diagnostic ignored "-Wpedantic"..

github.com:emersion (unverified) 2 years ago · edit

I'd rather not add pragma directives.

github.com:kennylevinsen (unverified) 2 years ago · edit

I guess one "solution" would be #pramga GCC diagnostic ignored "-Wpedantic"..

Seems easier to build without -Wpedantic than to add compiler-specific hacks to the source to mute it. :/

github.com:unrelentingtech (unverified) 2 years ago · edit

Well, yeah, but unfortunately some projects that include sd-bus.h use warning_level=3 werror=true by default ;) (though yeah that would affect actual systemd/elogind as well if someone used clang12, so not really a basu specific problem then)

github.com:emersion (unverified) 2 years ago · edit

The headers installed system-wide should be marked a "system includes" with -isystem by Meson, and warnings in these should get silenced automatically.

Unfortunately on FreeBSD Meson doesn't do it for /usr/local.

Register here or Log in to comment, or comment via email.