Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

clang -Wpedantic enum int range #36

Closed
valpackett opened this issue Apr 17, 2021 · 8 comments
Closed

clang -Wpedantic enum int range #36

valpackett opened this issue Apr 17, 2021 · 8 comments

Comments

@valpackett
Copy link

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
        ^                                            ~~~~~~~~~~~~~~~
@kennylevinsen
Copy link
Collaborator

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...

@emersion
Copy link
Owner

Has upstream systemd done something about this?

@kennylevinsen
Copy link
Collaborator

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.

@valpackett
Copy link
Author

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

@emersion
Copy link
Owner

I'd rather not add pragma directives.

@kennylevinsen
Copy link
Collaborator

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. :/

@valpackett
Copy link
Author

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)

@emersion
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants