apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karl Fogel <kfo...@galois.collab.net>
Subject Re: [PATCH] apr_getopt_long interface update and interleaving support
Date Sat, 25 Nov 2000 04:48:03 GMT
Greg Hudson <ghudson@MIT.EDU> writes:
> It wasn't "const char *const *argv" before because a "char **"
> argument is not compatible with such a parameter, and C programs
> canonically take "char **argv", not "const char *const *argv".  I'm
> not sure if it's even valid C to silently change from char * to const
> char * without an explicit cast, which is what you'd be doing if you
> wrote a main() which accepted a list of const char pointers intead of
> a list of char pointers.
> 
> (Branko said this as well, in different words.)

Just to second William Rowe's point about this, since we're trying to
use const wherever possible (in both APR and Subversion, I think):

Const is only important in lvalues.  The rules are

  1. It's okay to not modify something you were allowed to modify.
  2. It's not okay to modify something you were not allowed to modify.

Const doesn't change the type (storage size) of anything.  So a callee
can *always* add a const qualifier to its parameters, as long as it
then keeps that promise to never modify the data.

-K

Mime
View raw message