Messages in this thread | | | From | Vadim Lobanov <> | Subject | Re: Why is the kfree() argument const? | Date | Fri, 18 Jan 2008 11:06:08 -0800 |
| |
On Friday 18 January 2008 03:47:01 am Giacomo A. Catenazzi wrote: > Changing the name of variables in your example: > > extern print_int(const int *); > > int main(int argc, char **argv) > { > extern int errno; > > errno = 0; > print_int(&i); > return errno; > }
Except that changing int to extern int makes all the difference in the world: the variable went from being local to being global. The way const is currently defined, however, the compiler cannot take advantage of the fact that the variable was local in the former case.
> Ok, I changed int to extern int, but you see the point? > Do you want complex rules about const, depending on > context (extern, volatile,...) ?
Sometimes complexity is worth it.
-- Vadim Lobanov
| |