#include header guard format?

后端 未结 13 1654
广开言路
广开言路 2020-12-05 07:46

I know it makes little difference to a project but, assuming you use #defined header guards for your C++ code, what format do you use? e.g. assuming a header called f

13条回答
  •  醉酒成梦
    2020-12-05 08:20

    I'd go with the filepath + the boost _INCLUDED suffix plus the nowadays widely supported #pragma once

    In alot editors (for me its sublime) you can also define some macros/snippets for this.

    Here is one that does it for you:

    
        
        incguard
        include guard
    
    

    so yourproject/include/yourlib/yourfile.hpp

    becomes YOURLIB_YOURFILE_HPP_INCLUDED

    An additional external source code style checker tool could easily track consistency of your guards this way.

提交回复
热议问题