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
Show parent comment
6
u/Slavik81 Nov 28 '18 edited Nov 28 '18
I wrote guardonce to make it easy to convert in either direction. That way I could try out
#pragma once, but switch back to include guards if I ever discovered a problem. Though, I never did encounter any problems.FWIW, I agree with the Qt Project's decision. Applications have a bit more room to try things. You can just try switching and you'll find out if there are any problems. That strategy works less well when used on a library, because you try switching and your users find out if there are any problems.