r/C_Programming • • 27d 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

Show parent comment

2

u/sto_babbalucco69420 27d ago

for the niche usage i'm guessing u could do the define at the top before whatever that can include "foo.h"? maybe even wrap it with an ifndef if it's useful for some reason. i feel like it should work for cases like DEBUG or FOO_IMPLEMENTATION, i can't think of anything else