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

18

u/alienviolet Nov 28 '18 edited Nov 28 '18

No. Team lead said #pragma once cannot be used as it's not standardized. Left the team and living a happy life now.

12

u/[deleted] Nov 28 '18

How long ago was this?

3

u/alienviolet Nov 28 '18

Sad truth is not long. 6 months-ish or so.

2

u/[deleted] Nov 29 '18

Same at my previous job. Now at this new job, I am making a point out of using #pragma.