[syslog-ng]Trying to compile with SUN's cc compiler.

Balazs Scheidler syslog-ng@lists.balabit.hu
Wed, 30 Apr 2003 10:09:45 +0200


On Tue, Apr 29, 2003 at 01:56:20PM -0400, Jay Davis wrote:
> Here is the results after running make.
> 
> I had to change this in the configure file:
> if test $enable_debug = "yes"; then
>         CFLAGS="-Wall -g"
> else
> #       CFLAGS="-Wall -O2"
>         CFLAGS="-w -fast"
> fi
> 
> -fast is optimzed. -w is supress warnings.
> 
> The offending line in objbase.h is:
> 
> #ifdef DEBUG_ALLOC
> 
> struct ol_string_header
> {
>   int magic; /* For a sentinel value */
> };
> 
> #else   /* !DEBUG_ALLOC */
> 
> struct ol_string_header {};   <--------------Line 67.
> 
> #endif  /* !DEBUG_ALLOC */
> 
> 
> My C is a little old. I'll have to crack out my very old Kernigan book.
> Can you create a null pointer to a struct like that? Is this a picky
> compiler and should ignore it? I was able to get this compiled using.
> gcc. I HAVE to get this compiled with the SUN compiler. Yes I am brave.

try this patch:

Index: objbase.h
===================================================================
RCS file: /var/cvs/syslog-ng/libol/src/objbase.h,v
retrieving revision 1.3
diff -u -r1.3 objbase.h
--- objbase.h	10 Jul 1999 13:23:09 -0000	1.3
+++ objbase.h	30 Apr 2003 08:08:52 -0000
@@ -57,26 +57,27 @@
 
 #ifdef DEBUG_ALLOC
 
-struct ol_string_header
+struct ol_string
 {
-  int magic; /* For a sentinel value */
+  int magic;
+  UINT32 use_cnt;
+  /* NOTE: The allocated size may be larger than the string length. */
+  UINT32 length;
+  UINT8 data[1];
 };
 
-#else   /* !DEBUG_ALLOC */
-
-struct ol_string_header {};
 
-#endif  /* !DEBUG_ALLOC */
+#else   /* !DEBUG_ALLOC */
 
 struct ol_string
 {
-  struct ol_string_header header;
-
   UINT32 use_cnt;
   /* NOTE: The allocated size may be larger than the string length. */
   UINT32 length;
   UINT8 data[1];
 };
+
+#endif  /* !DEBUG_ALLOC */
 
 struct ol_string *ol_string_alloc(UINT32 length);
 void ol_string_free(struct ol_string *s);
Index: xalloc.c
===================================================================
RCS file: /var/cvs/syslog-ng/libol/src/xalloc.c,v
retrieving revision 1.9
diff -u -r1.9 xalloc.c
--- xalloc.c	16 Sep 2002 08:23:22 -0000	1.9
+++ xalloc.c	30 Apr 2003 08:08:52 -0000
@@ -211,7 +211,7 @@
 	struct ol_string *s
 		= xalloc(sizeof(struct ol_string) - 1 + length);
 #ifdef DEBUG_ALLOC
-	s->header.magic = -1717;
+	s->magic = -1717;
 #endif
 	s->length = length;
 	s->use_cnt = 1;
@@ -229,9 +229,9 @@
 	assert(s->use_cnt);
 	if (--s->use_cnt == 0) {
 #ifdef DEBUG_ALLOC
-		if (s->header.magic != -1717)
+		if (s->magic != -1717)
 			fatal("ol_string_free: Not string!\n");
-		s->header.magic = 9999;
+		s->magic = 9999;
 #endif
 		ol_free(s);
 	}


-- 
Bazsi
PGP info: KeyID 9AF8D0A9 Fingerprint CD27 CFB0 802C 0944 9CFD 804E C82C 8EB1