C: On including a file twice I get errors reporting redefinition of function. How can I avoid duplicate inclusion?
On including a file twice I get errors reporting redefinition of function. How can I avoid duplicate inclusion?
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 the name of the file to be included is 'goto.h' then replace filename_h with 'goto_h'.




Comments
Log in or create a user account to comment.