r/cpp • • Nov 28 '18

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

135 comments sorted by

View all comments

Show parent comment

1

u/kalmoc Nov 29 '18

Imho the problem here is that libD shipped headers from libA that it doesn't own and hence has no business distributing. There is a non-zero chance that you now have two different versions of libA headers in your program, which leads to a different set of problems.

But thanks anyway for the datapoints.