Q
I am reading a book. It introduces ifndef as the following:
--------------------------------------------------------------------------------------
Look at the following code:
#ifndef _CONST_H_INCLUDED_
/* define constants */
#define _CONST_H_INCLUDED_
#endif /* _CONST_H_INCLUDED_ */
When const.h is included, it defines the symbol _CONST_H_INCLUDED_. If
that symbol is already defined (because the file was included earlier),
the #ifndef conditional hides all defines so they don't cause
trouble.
--------------------------------------------------------------------------------------
I don't quite understand why we need to define a symbol in this way.
What does it tell?
Anyone can explain to me?
Thanks a lot!
--------------------------------------------------------------------------------------
Look at the following code:
#ifndef _CONST_H_INCLUDED_
/* define constants */
#define _CONST_H_INCLUDED_
#endif /* _CONST_H_INCLUDED_ */
When const.h is included, it defines the symbol _CONST_H_INCLUDED_. If
that symbol is already defined (because the file was included earlier),
the #ifndef conditional hides all defines so they don't cause
trouble.
--------------------------------------------------------------------------------------
I don't quite understand why we need to define a symbol in this way.
What does it tell?
Anyone can explain to me?
Thanks a lot!