Menu

#154 builtin implementation of snprintf doesn't work

Feature Request
open
nobody
None
5
2021-03-25
2021-03-25
No

When cross-compiling log4cpp, the detection of snprintf by the autotools macro does not work and by default assumes that snprintf is not available.
As a result it uses an internal implementation of snprintf, unfortunately, that's broken, and logs are not correctly formatted.

Her is a suggested fix for the cross compiling case. It assumes that snprintf is always available in this case, which may not be how you want to fix this:

diff --git a/m4/AC_FUNC_SNPRINTF.m4 b/m4/AC_FUNC_SNPRINTF.m4
index 08af521..e2bfc51 100644
--- a/m4/AC_FUNC_SNPRINTF.m4
+++ b/m4/AC_FUNC_SNPRINTF.m4
@@ -15,7 +15,7 @@ AC_DEFUN([AC_FUNC_SNPRINTF],
 [AC_TRY_RUN([#include <stdio.h>
 int main () { int l = snprintf(NULL,0,"%d",100); exit (!((3 <= l) || (-1 == l))); }
 ], ac_cv_func_snprintf=yes, ac_cv_func_snprintf=no,
-ac_cv_func_snprintf=no)])
+ac_cv_func_snprintf=yes)])
 if test $ac_cv_func_snprintf = yes; then
   AC_DEFINE(HAVE_SNPRINTF,,[define if the C library has snprintf])
 fi

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.