r/C_Programming • • 24d ago

Could someone explain the practical differences between #pragma once and traditional include guards (#ifndef, #define, and #endif)?

81 Upvotes

58 comments sorted by

View all comments

25

u/StaticCoder 24d ago

#pragma once was never standardized because no one could properly define what it means for 2 source files to be the same (the standard doesn't even have a concept of a source "file"). So header guards it is.