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

-5

u/Feer_C9 27d ago

since when gcc supports pragma once? Last time I checked it didn't. Maybe I'm old

50

u/Gutrix_HD 27d ago

GCC has supported #pragma once since v3.4 (2004).

You should probably update your compiler.

16

u/UltimaN3rd 27d ago

It's been supported since GCC 3.4 (2004): https://gcc.gnu.org/gcc-3.4/changes.html

11

u/Feer_C9 27d ago

lol I thought it didn't, looks like I didn't search right