[Crash-utility] [PATCH makedumpfile v2 2/4] Avoid LONG_MAX/ULONG_MAX redefinitions

HATAYAMA Daisuke d.hatayama at jp.fujitsu.com
Thu Feb 23 01:34:05 UTC 2012


common.h locally defines LONG_MAX and ULONG_MAX. But when importing
lzo library's headers, ulimit.h that is imported implicitly is also
imported so the two definitions collide, and the warning message below
is displayed.

gcc -g -O2 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DVERSION='"1.4.2"' -DRELEASE_DATE='"25 January 2012"' -D__x86_64__ -DUSELZO  print_info.o dwarf_info.o elf_info.o erase_info.o sadump_info.o arch/arm.o arch/x86.o arch/x86_64.o arch/ia64.o arch/ppc64.o arch/s390x.o -o makedumpfile makedumpfile.c -llzo2 -ldw -lbz2 -lebl -ldl -lelf -lz
In file included from makedumpfile.h:37:0,
                 from makedumpfile.c:16:
common.h:23:0: warning: "LONG_MAX" redefined
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/limits.h:132:0: note: this is the location of the previous definition
common.h:24:0: warning: "ULONG_MAX" redefined
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/limits.h:136:0: note: this is the location of the previous definition

To avoid this problem, check if each has already defiend before
defining it.

Signed-off-by: HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com>
---

 common.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/common.h b/common.h
index a4cc2f7..6ad3ca7 100644
--- a/common.h
+++ b/common.h
@@ -20,8 +20,12 @@
 #define FALSE		(0)
 #define ERROR		(-1)
 
+#ifndef LONG_MAX
 #define LONG_MAX	((long)(~0UL>>1))
+#endif
+#ifndef ULONG_MAX
 #define ULONG_MAX	(~0UL)
+#endif
 #define ULONGLONG_MAX	(~0ULL)
 
 #define MAX(a,b)	((a) > (b) ? (a) : (b))




More information about the Crash-utility mailing list