in , , , ,

POV: you’re learning C++ (you regret this deeply)

POV: you're learning C++ (you regret this deeply) | bugs-memes, c++-memes, bug-memes, performance-memes, warning-memes, error-memes, fix-memes, search-memes, compiler-memes, IT-memes, rds-memes, mac-memes, bot-memes, header-memes, cookie-memes | ProgrammerHumor.io
bugs-memes, c++-memes, bug-memes, performance-memes, warning-memes, error-memes, fix-memes, search-memes, compiler-memes, IT-memes, rds-memes, mac-memes, bot-memes, header-memes, cookie-memes | ProgrammerHumor.io

[text] 199 169 Tjust wanted to add to this discussion that 1 am just compiling on VS and GCC and used to use include guards. I have now switched to pragna once and the only reason for me is not performance or portability or standard as I donit really care what is standard as long s VS and GCC supportit and that is that pragna once reduces possibilities for bugs. Itis all too easy to copy and paste a header file to another header file modify it to suit ones needs and forget to change the name of the include guard. Once both are included it takes you a while to track down the error as the error messages arent necessarily clear. Share Follow edited Nov 30 2014 at 957 answered Jul 22 2011 at 1655 Cookie 117k 13 52 o381 5 This is the correct reason. Forget performancewe should use pragma once because its less error prone. It occurs to me that if compilers are already tracking include guards theyre already doing most of the work necessary to issue warnings when they see different files using the same macro name. rieu Jun 132019 at 636 pragma once has unfixable bugs. It should never be used. If your include search path is sufficiently complicated the compiler may be unable to tell the difference between two headers with the same basename e.g. afoo.h and bfoo.h so a pragna once in one of them will suppress both. It may also be unable to tell that two different relative includes e.g. include foo.h and include ..afoo.h refer to the same file so pragna once will fail to suppress a redundant include when it should have.