From: Bruno Haible Date: Sat, 17 Jan 2026 00:52:09 +0000 (+0100) Subject: selinux-h: Fix compilation errors and link errors in C++ mode. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=144b720464f562e878fb0dadbee2071345cdb61d;p=thirdparty%2Fgnulib.git selinux-h: Fix compilation errors and link errors in C++ mode. * lib/se-selinux.in.h: Mark the functions as 'extern "C"'. * lib/se-label.in.h: Mark the functions as 'extern "C"'. Avoid implicit casts from 'void *' to other pointer types. * lib/se-context.in.h: Likewise. (context_t): Don't use 'struct context_t'. --- diff --git a/ChangeLog b/ChangeLog index e104502a27..a8555e59e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2026-01-16 Bruno Haible + + selinux-h: Fix compilation errors and link errors in C++ mode. + * lib/se-selinux.in.h: Mark the functions as 'extern "C"'. + * lib/se-label.in.h: Mark the functions as 'extern "C"'. Avoid implicit + casts from 'void *' to other pointer types. + * lib/se-context.in.h: Likewise. + (context_t): Don't use 'struct context_t'. + 2026-01-16 Paul Eggert manywarnings: omit new C warning for GCC < 15 diff --git a/lib/se-context.in.h b/lib/se-context.in.h index 37cc7a6dff..ca6e97a14f 100644 --- a/lib/se-context.in.h +++ b/lib/se-context.in.h @@ -41,14 +41,18 @@ _GL_INLINE_HEADER_BEGIN # endif #endif +#ifdef __cplusplus +extern "C" { +#endif + -typedef struct context_t *context_t; +typedef struct selinux_context_t *context_t; SE_CONTEXT_INLINE context_t context_new (char const *_GL_UNNAMED (s)) - { errno = ENOTSUP; return (void *) 0; } + { errno = ENOTSUP; return (context_t) 0; } SE_CONTEXT_INLINE char * context_str (context_t _GL_UNNAMED (con)) - { errno = ENOTSUP; return (void *) 0; } + { errno = ENOTSUP; return (char *) 0; } SE_CONTEXT_INLINE void context_free (context_t _GL_UNNAMED (c)) {} SE_CONTEXT_INLINE int @@ -65,16 +69,21 @@ context_type_set (context_t _GL_UNNAMED (sc), char const *_GL_UNNAMED (s)) { errno = ENOTSUP; return -1; } SE_CONTEXT_INLINE char * context_type_get (context_t _GL_UNNAMED (sc)) - { errno = ENOTSUP; return (void *) 0; } + { errno = ENOTSUP; return (char *) 0; } SE_CONTEXT_INLINE char * context_range_get (context_t _GL_UNNAMED (sc)) - { errno = ENOTSUP; return (void *) 0; } + { errno = ENOTSUP; return (char *) 0; } SE_CONTEXT_INLINE char * context_role_get (context_t _GL_UNNAMED (sc)) - { errno = ENOTSUP; return (void *) 0; } + { errno = ENOTSUP; return (char *) 0; } SE_CONTEXT_INLINE char * context_user_get (context_t _GL_UNNAMED (sc)) - { errno = ENOTSUP; return (void *) 0; } + { errno = ENOTSUP; return (char *) 0; } + + +#ifdef __cplusplus +} +#endif _GL_INLINE_HEADER_END diff --git a/lib/se-label.in.h b/lib/se-label.in.h index 159adb6693..f1f6d2dbad 100644 --- a/lib/se-label.in.h +++ b/lib/se-label.in.h @@ -42,6 +42,11 @@ _GL_INLINE_HEADER_BEGIN # endif #endif +#ifdef __cplusplus +extern "C" { +#endif + + #define SELABEL_CTX_FILE 0 struct selabel_handle; @@ -64,12 +69,17 @@ SE_LABEL_INLINE struct selabel_handle * selabel_open (int _GL_UNNAMED (backend), struct selinux_opt *_GL_UNNAMED (options), unsigned _GL_UNNAMED (nopt)) -{ errno = ENOTSUP; return (void *) 0; } +{ errno = ENOTSUP; return (struct selabel_handle *) 0; } SE_LABEL_INLINE void selabel_close (struct selabel_handle *_GL_UNNAMED (hnd)) { errno = ENOTSUP; } + +#ifdef __cplusplus +} +#endif + _GL_INLINE_HEADER_END #endif diff --git a/lib/se-selinux.in.h b/lib/se-selinux.in.h index a62de9c9df..8094bc13aa 100644 --- a/lib/se-selinux.in.h +++ b/lib/se-selinux.in.h @@ -50,6 +50,11 @@ _GL_INLINE_HEADER_BEGIN # endif # endif +# ifdef __cplusplus +extern "C" { +# endif + + # if !GNULIB_defined_security_types typedef unsigned short security_class_t; @@ -153,6 +158,11 @@ matchpathcon_init_prefix (char const *_GL_UNNAMED (path), # define GNULIB_defined_security_types 1 # endif + +# ifdef __cplusplus +} +# endif + _GL_INLINE_HEADER_END # endif /* _@GUARD_PREFIX@_SELINUX_SELINUX_H */