   #pragma once vs. include guards
  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?   
  I use include guards, simply because Code::Blocks puts them there for me :)I'm unsure there will be any difference between the two, I think most compilers have now caught up and handle it accordingly. Maybe some console developers here have some opinions?;  Supposedly, if #pragma once works, it might improve compilation time.The only thing is it could not work, but as the above post mentions, I think they smoothed that over.   ;  I always use header guards as they are guaranteed to always work.   ;  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.   ;  Include guards will never hurt.Pragma once will never hurt.So I use both together.   ;Quote:Original post by PromitPragma 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.   ;  #pragma once is not guaranteed to be supported on all compiliers. Thus I personally use inclusion guards.   ;Quote:Original post by Crypter#pragma once is not guaranteed to be supported on all compiliers. Thus I personally use inclusion guards.Yup that was my understanding and so I see inclusion guards being used in any books that are trying to be portable like Stroustroup's.I just finished reading Horton's book on Visual Studio and he uses #pragma once all through the book and even admits it may not work on all compilers but still uses it since that's what Visual Studio uses. Personally, I use #pragma once if I can get away with it since I'm a lazy programmer and it's less typing;)p.s. Actually, if you are using any of the various Microsoft wizards to generate MFC programs or something else it will automatically stick #pragma once in your header files for you![Edited by - daviangel on September 28, 2008 5:14:19 PM];Quote:Original post by SiCraneQuote:Original post by PromitPragma 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.Although it seems odd to have symlinks or hardlinks involved, I suppose that's a fair enough reason otherwise.   