[PATCH 1 of 2] chg: define PRINTF_FORMAT_ for non gnu C compiler

Jun Wu quark at fb.com
Sun Mar 20 18:55:49 EDT 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1458512725 25200
#      Sun Mar 20 15:25:25 2016 -0700
# Node ID cab48617a18dbccb5286ed8f90bfa608fe1d9f90
# Parent  83127a9fe76ea8b9379d9efa3afefff075b4f920
chg: define PRINTF_FORMAT_ for non gnu C compiler

Before this patch, if __GNUC__ is not defined, PRINTF_FORMAT_ will not be
defined and will cause compilation error.

This patch solves the issue by making sure PRINTF_FORMAT_ is defined. It
allows chg to be compiled with tcc (http://bellard.org/tcc/) by:

  tcc -o chg *.c

diff --git a/contrib/chg/util.h b/contrib/chg/util.h
--- a/contrib/chg/util.h
+++ b/contrib/chg/util.h
@@ -12,6 +12,8 @@
 
 #ifdef __GNUC__
 #define PRINTF_FORMAT_ __attribute__((format(printf, 1, 2)))
+#else
+#define PRINTF_FORMAT_
 #endif
 
 void abortmsg(const char *fmt, ...) PRINTF_FORMAT_;


More information about the Mercurial-devel mailing list