In Keil demos, I find some definitions such as "#ifndef __C51__", what's the meaning for double '_'.
"I don't know the difference between definition and declaration" Read K&R, and see this thread: http://www.keil.com/forum/docs/thread1847.asp Basically, a definition creates code and/or data; a declaration merely informs the compiler about code and/or data. Therefore, declarations are good in headers; definitions are bad! "compiler does not allow me to declare a variable in H file" Nonsense! The compiler doesn't care - it will let you have both definitions and declarations in headers. If you get errors when you declare (or, more likely, define) a variable in a Header file, it has nothing to do with the fact that it's in a header file per se; more likely you are falling into one of the pitfalls which is why we say: don't define code or data in headers!