libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compiler warning


From: Ralf Wildenhues
Subject: Re: compiler warning
Date: Thu, 8 Dec 2005 18:27:21 +0100
User-agent: Mutt/1.5.11

Hi Eric,

* Eric Blake wrote on Thu, Dec 08, 2005 at 02:49:19PM CET:
>
> libltdl/ltdl.c:2042: warning: passing arg 1 of `free' discards qualifiers
> from pointer target type
> 
> So, should we change libltdl/libtldl/lt__alloc.h to have the FREE(mem)
> macro cast away const by calling free ((void *) mem),

Yes,

> or should we change libltdl/ltdl.c so that lt__interface_id.id_string
> is just char* instead of const char*,

not unless there are other compelling reasons for it,

> or should we do this nasty approach:

no, really!

I've applied this to HEAD.

Thanks!
Ralf

2005-12-08  Eric Blake  <address@hidden>

        * libltdl/libltdl/lt__alloc.h (FREE): Cast away constness of
        argument to `free' to avoid compiler warning.

Index: libltdl/libltdl/lt__alloc.h
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/libltdl/lt__alloc.h,v
retrieving revision 1.2
diff -u -r1.2 lt__alloc.h
--- libltdl/libltdl/lt__alloc.h 22 Apr 2005 10:10:30 -0000      1.2
+++ libltdl/libltdl/lt__alloc.h 8 Dec 2005 17:26:05 -0000
@@ -37,10 +37,10 @@
 #define MALLOC(tp, n)          (tp*) lt__malloc((n) * sizeof(tp))
 #define REALLOC(tp, mem, n)    (tp*) lt__realloc((mem), (n) * sizeof(tp))
 #define FREE(mem)                                      LT_STMT_START { \
-       if (mem) (mem) = (free (mem), (void *) 0);      } LT_STMT_END
+       if (mem) (mem) = (free ((void *)mem), (void *) 0);      } LT_STMT_END
 #define MEMREASSIGN(p, q)                              LT_STMT_START { \
        if ((p) != (q)) { if (p) free (p); (p) = (q); (q) = 0; }        \
-                                                       } LT_STMT_END
+                                                               } LT_STMT_END
 
 /* If set, this function is called when memory allocation has failed.  */
 LT_SCOPE void (*lt__alloc_die) (void);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]