Juniper / libxo

The libxo library allows an application to generate text, XML, JSON, and HTML output using a common set of function calls. The application decides at run time which output style should be produced.
http://juniper.github.io/libxo/libxo-manual.html
BSD 2-Clause "Simplified" License
314 stars 47 forks source link

Incorrect usage of an internal Glibc header (sys/cdefs.h) #94

Open xplshn opened 5 months ago

xplshn commented 5 months ago
/usr/include/sys/cdefs.h:4:2: warning: usage of non-standard #include <sys/cdefs.h> is deprecated [-W#warnings]
    4 | #warning usage of non-standard #include <sys/cdefs.h> is deprecated

Developers like to wrongly include sys/cdefs.h to use the _*_DECLS macros. This is a bug and the correct way to do it is to use:

#ifdef __cplusplus
extern "C" {
#endif

Instead of:

#ifdef __cplusplus
}
#endif

And instead of _END_DECLS

https://wiki.gentoo.org/wiki/Musl_porting_notes

This causes problems on other OSes, like Illumos based ones, such as OpenIndiana, and also when */Linux based distros that use Musl, uClibc, Bionic libc (Android libc) or anything other than glibc try to compile libxo

philshafer commented 3 months ago

Not sure what the problem here is, given that I don't include cdefs.h and the only place cplusplus is referenced is in xo_config.h.in::

% egrep 'cdefs|cplusplus' /.[hc]* libxo/xo_config.h.in:#ifndef __cplusplus libxo/xo_config.h.in~:#ifndef __cplusplus

Could you please give me some additional information? FWIW libxo compiles for FreeBSD, which is non-glibc based. Also for macos (clang).

Thanks, Phil

xplshn commented 3 months ago

The problem is that it won't compile in Musl, due to GETTEXT, the Chimera Linux OS has patched LIBXO to work on Musl-based Linuxes. They've also added support for BMAKE, tho that's not necessary.

--- a/configure
+++ b/configure
@@ -14375,11 +14375,11 @@ if test "$GETTEXT_ENABLE" != "no"; then
 printf %s "checking gettext in ${GETTEXT_PREFIX}... " >&6; }

   _save_cflags="$CFLAGS"
-  CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror -lintl"
+  CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror"
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <libintl.h>
-             int main() {char *cp = dgettext(NULL, "xx"); return 0; }
+             int main() {char *cp = dgettext(0, "xx"); return 0; }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"
 then :
@@ -14401,11 +14401,11 @@ printf "%s\n" "$HAVE_GETTEXT" >&6; }
 printf %s "checking gettext in ${GETTEXT_PREFIX}... " >&6; }

       _save_cflags="$CFLAGS"
-      CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror -lintl"
+      CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror"
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <libintl.h>
-                 int main() {char *cp = dgettext(NULL, "xx"); return 0; }
+                 int main() {char *cp = dgettext(0, "xx"); return 0; }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"
 then :
@@ -14428,11 +14428,11 @@ printf "%s\n" "$HAVE_GETTEXT" >&6; }
 printf %s "checking gettext in ${GETTEXT_PREFIX}... " >&6; }

       _save_cflags="$CFLAGS"
-      CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror -lintl"
+      CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror"
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <libintl.h>
-                 int main() {char *cp = dgettext(NULL, "xx"); return 0; }
+                 int main() {char *cp = dgettext(0, "xx"); return 0; }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"
 then :
@@ -14455,7 +14455,7 @@ if test "$HAVE_GETTEXT" = "yes"; then
 printf "%s\n" "#define HAVE_GETTEXT 1" >>confdefs.h

     GETTEXT_CFLAGS="-I${GETTEXT_PREFIX}/include"
-    GETTEXT_LIBS="-L${GETTEXT_PREFIX}/lib -lintl"
+    GETTEXT_LIBS="-L${GETTEXT_PREFIX}/lib"
 else
     GETTEXT_PREFIX=none
     GETTEXT_CFLAGS=

https://github.com/chimera-linux/cports/tree/master/main/libxo/patches

Regards, Xplshn