Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Language%20in%20C%20Interview%20Questions%20and%20Answers

Question: On including a file twice I get errors reporting redefinition of function.
How can I avoid duplicate inclusion?
Answer: Redefinition errors can be avoided by using the following macro definition. Include this definition in the header file.
#if !defined filename_h
#define filename_h
/* function definitions */
#endif
Replace filename_h with the actual header file name. For example, if name of file to be included is 'goto.h' then replace filename_h with 'goto_h'.
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook