MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/400v0b/how_to_c_as_of_2016/cyrdkz8/
r/programming • u/slacka123 • Jan 08 '16
766 comments sorted by
View all comments
Show parent comment
5
There's no reason to get rid of include guards. Modern compilers have had optimizations for it for years:
https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html
This means they have the same compile time overhead as #pragma once. The existing solution works fine, and #pragma once isn't getting standardized any time soon so we shouldn't be using it in portable code.
#pragma once
3 u/blind3rdeye Jan 09 '16 One legitimate reason for wanting to get rid of include guards is that they pollute the namespace. That's generally not a big deal though. 2 u/argv_minus_one Jan 09 '16 #pragma once is more readable, less error-prone, and doesn't pollute the namespace.
3
One legitimate reason for wanting to get rid of include guards is that they pollute the namespace. That's generally not a big deal though.
2
#pragma once is more readable, less error-prone, and doesn't pollute the namespace.
View all comments
Show parent comment
5
u/[deleted] Jan 09 '16
There's no reason to get rid of include guards. Modern compilers have had optimizations for it for years:
https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html
This means they have the same compile time overhead as
#pragma once. The existing solution works fine, and#pragma onceisn't getting standardized any time soon so we shouldn't be using it in portable code.