课本上的不一定是对的
是不是还有个.h文件 变量应该都在那个里面定义的 然后在.c里面includ一下应该就ok
#include <red51.h>错误应该是 #include <reg51.h>
头文件的文件名写错了