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

20

u/Mr_Engineering 21d ago

#pragma provides compiler specific instructions and therefore nothing about it is standard or guaranteed to be portable.

Include guards are standard by implication and therefore are portable

1

u/juanfnavarror 21d ago

#pragma is compiler specific and not standard or portable. Except for most platforms and compilers that you might choose!!!!!