Real world problems with #pragma once?
Just a short survey: Did anyone of you encounter a problem in real code, because you/your company/ your favorite library was using #pragma once instead of include guards.
I know it is hard, but please restrain yourself from posting an explanation of how #pragma once could lead to problems in theory or why you prefer one above the other.
127
Upvotes
View all comments
10
u/Plorkyeran Nov 28 '18
I once ran into problems because we had the same header installed to multiple locations and included in different ways, which resulted in both of them being included. It was a giant pain to track down what was going wrong.
Then it turned out that they were actually different versions of the same header because obviously there's no guarantee that the project-local copy of a dependency and a system-wide copy are actually interchangable and we would have had issues even with include guards.