#ifndef and #pragma once

Is it just for compiler compatibility that we use #indef instead of #pragma once since both work in this case?

2 Likes

I would say yes that’s the right reason.

All #pragma directives are compiler specific, so if there’s a generically accepted, works-everywhere solution, then go with it. As soon as you use a #pragma it may behave unexpectedly when the code is compiled elsewhere as the compiler is free to just ignore it completely if it wants to.

I think this is also one of those “it’s the right thing to do out in the world” vs. “I’m in an indie dev and will only be compiling my stuff, my way, in my tools” :smiley: so balance that as you may.

3 Likes

Like the indie developper who wrote all source code in Unreal Engine :joy:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms