[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: BeOS PPC Compilation Fixes

From: Sam TH <sam_at_uchicago.edu>
Date: 2000-12-03 11:35:55 CET

On Sun, Dec 03, 2000 at 01:57:44AM -0800, Greg Stein wrote:
> >...
> > > Now that is just a dumb compiler if it is complaining about those. "char *"
> > > can legally be passed to a "const char *" function. The other possibility is
> > > that it doesn't think that "char foo[]" is compatible with "char *foo" --
> > > again, a big problem with the compiler.
> > >
> > > [ I believe both of those issues are consider "standard C" and we shouldn't
> > > "have" to cast. ]
> > >
> > > Which of the two problems is the compiler talking about? const or [] ?
> >
> > The problem is with the const. I couldn't find anything about the
> > standard either way in a quick Google search.
>
> Urk. That is really bad. I'm surprised you aren't seeing more widespread
> problems. The rule is pretty simple:
>
> void foo(const char *bar)
>
> You can pass a "const char *baz" or a "char *baz" to the above function.
> Both values are "char *" and the function says "I won't modify it."
>
> We aren't in a position to retrofit the whole codebase to insert casts to
> include "const" to compensate for a poor compiler. All of those casts would
> end up hiding a typing bug at some point in the future (which is why I hate
> casts).

Ok, take back everything I said about this. It should work without
those changes. I was just overzealous in adding casts to the calls to
that function. Ignore this patch.

/me votes -1 on /me. :-0

Thanks
           
        sam th
        sam@uchicago.edu
        http://www.abisource.com/~sam/
        GnuPG Key:
        http://www.abisource.com/~sam/key

  • application/pgp-signature attachment: stored
Received on Sat Oct 21 14:36:16 2006

This is an archived mail posted to the Subversion Dev mailing list.