Original Post
I have read up on the pros and cons of #pragma once and include guards but I wanted to get a few opinions. Do you find yourself using #pragma once or include guards?
Quote:
Original post by Promit
Pragma once will never hurt.
Quote:
Original post by Crypter
#pragma once is not guaranteed to be supported on all compiliers. Thus I personally use inclusion guards.
Quote:Although it seems odd to have symlinks or hardlinks involved, I suppose that's a fair enough reason otherwise.
Original post by SiCrane Quote:
Original post by Promit
Pragma once will never hurt.
Unless your code is compiled by an older version of gcc or LCC, both of which have had buggy implementation of pragma once such symbolic or hard links would confuse them.
Quote:
Overall, there should be no real difference between using internal guards and pragma directives (which happily confirms some of the measurements we had done in real code bases). So stick with internal guards, which are standard and work on any compiler, but if adding a #pragma once directive surrounded by conditionals (because it's not standard and it's not supported in all the compilers) in addition to the internal guards would make you sleep better, go for it. External guards might have an edge with Visual Studio, but the pain and potential trouble of using external guards clearly outweighs any speed benefits gained by using them.
Quote:
Original post by Promit
Although it seems odd to have symlinks or hardlinks involved, I suppose that's a fair enough reason otherwise.
Quote:
Original post by Evil Steve
Include guards. I really doubt that the time saved by using #pragma once will be noticible. If in doubt, you can always use both to get the best of both worlds.
Quote:
Original post by greenhybrid
Or accept the fact that your program will eventually only ever run on [a specific version of] Compiler X, or OS Y, or both.
Quote:
Original post by Yann
If you'd argue like this, you couldn't use any kind of language extension - that means no extended calling conventions, no DLLs, no intrinsics, etc. Which is obviously nonsense.
Quote:
Original post by geenhybrid
Or accept the fact that your program will eventually only ever run on [a specific version of] Compiler X, or OS Y, or both.
This topic has been locked by a moderator. New replies are not allowed.
GameDev.net uses cookies to ensure you have the best experience on our platform. Learn more