Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualEctara

Posted 05 February 2013 - 12:05 PM

One somewhat useless benefit of an include guard is that you can test the macro to see if a file has been included. Another equally useless benefit is that  you can undefine the macro to include the file again.

If you do the latter, question your design.

I, personally, always err on the side of standards-compliance, so that's what matters to me. If you are always using a certain compiler that has enormous benefits for #pragma once, and that is what you need, then go for it. Keep in mind, a compiler is allowed to implement #pragma once as syntactic sugar for an include guard with a long enough name to be guaranteed to be unique, and it is allowed to be slower than an include guard. Read the documentation on your compiler to see if it provides huge benefits, or if it provides none at all over include guards, like in GCC which optimizes include guard usage.


#1Ectara

Posted 05 February 2013 - 12:04 PM

One somewhat useless benefit of an include guard is that you can test the macro to see if a file has been included. Another equally useless benefit is that  you can undefine the macro to include the file again.

If you do the latter, question your design.

I, personally, always err on the side of standards-compliance, so that's what matters to me. If you are always using a certain compiler that has enormous benefits for #pragma once, and that is what you need, then go for it. Keep in mind, a compiler is allowed to implement #pragma once as syntactic sugar for an include guard with a long enough name to be guaranteed to be unique, and it is allowed to be slower than an include guard. Read the documentation on you compiler to see if it provides huge benefits, or if it provides none at all over include guards, like in GCC which optimizes include guard usage.


PARTNERS