[pacman-dev] [RFC] _RESERVED_IDS & enum assignments, take 2

ivy.foster at gmail.com ivy.foster at gmail.com
Sun Sep 4 03:14:48 UTC 2016


I've had another go at the patches from yesterday.

The first patch, which eliminates use of #define
_RESERVED_IDENTIFIERS, has one problem keeping me from adding
-Wreserved-id-macro to configure.ac: the autoconf-generated file
config.h.in contains one, _DARWIN_USE_64_BIT_INODE. I'm honestly not
sure how to prevent autoconf from adding this, or how to make it print
it at the very bottom after a "#pragma GCC system_header".

The second is a much more complete version of the patch that added
ALPM_ERR_OK. This version handles *every* enum type that is used by
functions that return either a member of that enum or an error, and
allows building cleanly with clang -Wassign-enum.

The RFC in the subject is because for patch #2, I discovered that a
common code pattern in pacman is using enum types to generate
bitfields. Technically, the resulting bitfield isn't a member of the
enum*, which caused many a warning with -Wassign-enum. As a quick and
dirty solution, I declared these bitfield variables to be ints rather
than (say) _alpm_siglevel_t. It encodes less information than
declaring them as the enum type, but is technically more accurate.
Would it be better to use unions or something?

Comments welcome. Cheers.

Ivy

*:
enum foo {
	BAR = 1 << 0, /* 01 */
	BAZ = 1 << 1; /* 10 */
	/* Not included: 11 */
}


More information about the pacman-dev mailing list