> D. Hugh Redelmeier wrote (about C):
> > If you define a variable to be const, it must not be changed by the
> > program. If, however, you have a pointer-to-const, it is possible
> > that the object pointed to may change due to other parts of the
> > program having non-const access.
> >
> > In other words, a pointer-to-const can point to something that isn't
> > const. But something that is const must not be changed.
> >
> > So, in the quoted example, gcc could assume (and even enforce) that
> > the variable isn't changed during its lifetime.
"const char *p", and "char const *p", both define a pointer to a constant
char, the char can't be changed, the pointer can.
"char * const p" defines a constant pointer to a char, you can't change
the pointer, but you can change the char.
"const" just means you can't read it, it's still a normal variable, just
one that the compiler doesn't allow you to change.
Q
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Tue Feb 29 2000 - 21:00:18 EST