Added gcc style printf argument check if supported.

Fixed benign warning in gtkclient exposed by this check.


git-svn-id: http://voip.null.ro/svn/yate@44 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2004-09-09 16:16:29 +00:00
parent d71c7bdb8f
commit 7a0f0091f4
3 changed files with 29 additions and 6 deletions

View File

@ -43,7 +43,7 @@ void g_atexit(GVoidFunc func)
it->func = func;
it->next = _g_atexit_func_head;
_g_atexit_func_head = it;
Debug(DebugInfo, "g_atexit: registered function 0x%08x\n", func);
Debug(DebugInfo, "g_atexit: registered function %p\n", func);
}
void g_atexit_unwind()
@ -51,7 +51,7 @@ void g_atexit_unwind()
g_atexit_func_t* it;
while(_g_atexit_func_head) {
_g_atexit_func_head->func();
Debug(DebugInfo, "g_atexit_unwind: called function 0x%08x\n", _g_atexit_func_head->func);
Debug(DebugInfo, "g_atexit_unwind: called function %p\n", _g_atexit_func_head->func);
it = _g_atexit_func_head;
_g_atexit_func_head = _g_atexit_func_head->next;
free(it);

View File

@ -7,6 +7,17 @@ AC_PROG_CXX
AC_PROG_CC
AC_PROG_AWK
# Check if gcc style printf argument check is supported
HAVE_GCC_FORMAT_CHECK=""
AC_MSG_CHECKING([for gcc printf format typechecks])
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wall -Werror"
AC_TRY_COMPILE([],[void f(void*x,const char*f,...) __attribute__((format(printf,2,3))); ],[ac_cv_format_checks=yes],[ac_cv_format_checks=no])
if [[ "x$ac_cv_format_checks" = "xyes" ]]; then
HAVE_GCC_FORMAT_CHECK="-DHAVE_GCC_FORMAT_CHECK"
fi
AC_MSG_RESULT([$ac_cv_format_checks])
# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
@ -281,7 +292,7 @@ AC_SUBST(HAVE_GTK)
AC_SUBST(GTK_INC)
AC_SUBST(GTK_LIB)
MODULE_CFLAGS="-fno-exceptions -fno-check-new -frtti -fPIC"
MODULE_CFLAGS="-fno-exceptions -fno-check-new -frtti -fPIC $HAVE_GCC_FORMAT_CHECK"
MODULE_LDFLAGS="-export-dynamic -shared -Wl,--retain-symbols-file,/dev/null"
AC_SUBST(MODULE_CFLAGS)
AC_SUBST(MODULE_LDFLAGS)

View File

@ -54,7 +54,11 @@ bool debugAt(int level);
* @param format A printf() style format string
* @return True if message was output, false otherwise
*/
bool Debug(int level, const char *format, ...);
bool Debug(int level, const char *format, ...)
#ifdef HAVE_GCC_FORMAT_CHECK
__attribute__((format(printf,2,3)))
#endif
;
/**
* Outputs a debug string for a specific facility.
@ -63,14 +67,22 @@ bool Debug(int level, const char *format, ...);
* @param format A printf() style format string
* @return True if message was output, false otherwise
*/
bool Debug(const char *facility, int level, const char *format, ...);
bool Debug(const char *facility, int level, const char *format, ...)
#ifdef HAVE_GCC_FORMAT_CHECK
__attribute__((format(printf,3,4)))
#endif
;
/**
* Outputs a string to the debug console with formatting
* @param facility Facility that outputs the message
* @param format A printf() style format string
*/
void Output(const char *format, ...);
void Output(const char *format, ...)
#ifdef HAVE_GCC_FORMAT_CHECK
__attribute__((format(printf,1,2)))
#endif
;
/**
* An object that logs messages on creation and destruction