#7858 Define C feature macros
Closed: fixed by cheimes. Opened by cheimes.

IPA's C source code relies on some non-standard features that are not available by default. So far the C code compiles fine because we rely on GCC with GNU extensions.

  • On Fedora 30, Samba uses memset_s from C11. The C11 extensions can be enabled with by using a C11 compiler (-std=c11) or __STDC_WANT_LIB_EXT1__=1.
  • strndup() is only defined by string.h with _POSIX_C_SOURCE=200809L or higher, see _POSIX_C_SOURCE >= 200809
  • htole16() is only defined by endian.h when _DEFAULT_SOURCE is defined, see htole16()
  • time_t is not defined by default. Code needs to include time.h.
  • typeof() is a GNU extension. There is the more generic __typeof__() extension. IPA uses only two calls to typeof(), both can be easily replaced by explicit type names.

All feature macros must be defined before including a header file. Since a lot of C files don't include config.h, it's easier to define the feature macros on the command line than in the project's config header file.

Thomas discovered the memset_s issue when mass-rebuild of F30 failed, http://koji.fedoraproject.org/koji/buildinfo?buildID=1186722


Metadata Update from @cheimes:
- Issue assigned to cheimes

master:

  • 93fb037d8409d9d46606c31d8a240e3963b72651 Compile IPA modules with C11 extensions

ipa-4-7:

  • 546b6b46abf8399aa9721bb28f4e4f96dc7ded1b Compile IPA modules with C11 extensions

Metadata Update from @cheimes:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

Metadata