I recently had to type in a small C test program and, in the process, I made a spelling mistake in the main function by accidentally using vooid
instead of void
.
And yet it still worked.
Reducing it down to its smallest complete version, I ended up with:
int main (vooid) {
return 42;
}
This does indeed compile (gcc -Wall -o myprog myprog.c
) and, when run, it returns 42.
How exactly is this valid code?
Here's a transcript cut and pasted from my bash
shell to show what I'm doing:
pax$ cat qq.c
int main (vooid) {
return 42;
}
pax$ rm qq ; gcc -Wall -o qq qq.c ; ./qq
pax$ echo $?
42