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

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

From: "Guy Harris" <gharris@xxxxxxxxx>
Date: Wed, 10 Aug 2005 16:30:16 -0700 (PDT)
Joerg Mayer wrote:

> I've been thinking about that problem a while ago and decided that we
> will have to live with that warning - at least until the libraries we
> are using write const char* instead of char* wherever appropriate.

Yes, but the question is *which* warning?

If the compiler *insists* on warning about *anything* that throws away the
const qualifier, you're stuck with the warning.  However, if some
compilers do, and some compilers allow you to cast away warnings, then

    int
    foo(char *p)
    {
        ...code that doesn't modify anything to which "p" points, so it
           really should have been declared as taking "const char *p"
           as its argument, but the people who wrote that library
           didn't think of that...
    }

        ...

    int
    bar(const char *p)
    {
        ...
        a = foo((char *)p);
        ...
    }

is arguably better (as in "quieter with some compilers") than

        ...
        a = foo(p);
        ...

*Both* will generate a warning with some compilers.  The first of those
might generate no warning with some compilers that will generate a warning
with the second of those.