Should I use #include in headers?

后端 未结 9 1174
甜味超标
甜味超标 2020-11-22 04:55

Is it necessary to #include some file, if inside a header (*.h), types defined in this file are used?

For instance, if I use GLib and wish to use the

9条回答
  •  旧巷少年郎
    2020-11-22 04:56

    I use the following construct to be sure, that the needed include file is included before this include. I include all header files in source files only.

    #ifndef INCLUDE_FILE_H
     #error "#include INCLUDE.h" must appear in source files before "#include THISFILE.h"
    #endif
    

提交回复
热议问题