Re: Performance tweaks

From: Q (
Date: Sun Feb 27 2000 - 17:36:37 EST

> 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.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

This archive was generated by hypermail 2b29 : Tue Feb 29 2000 - 21:00:18 EST