In Keil demos, I find some definitions such as "#ifndef __C51__", what's the meaning for double '_'.
Some points need clarification here, I think: *) Even in a single-source-file project, you should make it a habit to always have multiple-inclusion guards on your header files. Never write any .h file without one --- odds are it'll save your day years later, even if it's not actually needed right now. *) You say: "I don't know the difference between definition and declaration". That's exactly the reason you're having problems with header files. To declare a variable in a header file, write:
extern type_name variable_name;