Ethereal-dev: Re: [Ethereal-dev] Re: [Ethereal-cvs] rev 15286: /trunk/gtk/:capture_prefs.c col

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Thomas Steffen <steffen.list.account@xxxxxxxxx>
Date: Thu, 11 Aug 2005 11:27:31 +0200
On 8/11/05, Guy Harris <gharris@xxxxxxxxx> wrote:
>     int
>     bar(const char *p)
>     {
>         ...
>         a = foo((char *)p);
>         ...
>     }
> 
> is arguably better (as in "quieter with some compilers") than
> 
>         ...
>         a = foo(p);
>         ...

Yes, I ofter have the same problem, sometimes it is also with (char*)
and (unsigned char*). While the cast is quieter, I don't think it is
the better solution, because it basically the little typechecking
there is in C.

libxml2 has a nice macro for this,  BAD_CAST. You can compile the code
with this macro empty and disable const warnings to check the pointer
type, and you can define the macro to (char*) and compile with all
warnings on.

This still does not solve the gcc4 problem (I guess you just have to
disable the warning), but it should make life a little bit safer.

But I just read that Joerg has the opposite opinion, so it may be a
matter of taste.

Thomas