Name: Anonymous 2011-09-25 10:47
How exactly do register variables work in C? When should they be used? K&R touches upon them briefly but moves right along. Is there any source in which I can read about them in depth?
register int i;
int* a = &i;
&i
will prevent i
from being allocated in only a register. But maybe I'm wrong.
auto
, to confuse new programmers.
volatile
is also only a hint which the compiler is free to ignore. It would make the compiler useless for real code so they don't, but it's perfectly legal for them to do so.
int a[0];
int main(int argc, char** argv) {
void this_variable_has_no_usable_type_lol;
printf("And you can do this on old compilers it seems.\n");
printf("although modern ones don't seem to like it.");
return 0;
}
register
. You will only limit your possibilities doing so (de/referencing). Most modern compilers will optimize your program so that you wouldn't really spot performance differences anyway. Also, I am aware of some compilers/parsers that will ignore this keyword fully.void emptyvar;
int emptyarray[0];
printf("A = %d, B = %d\n", emptyvar, emptyarray[0]);