Closed MatthewChristoff closed 3 years ago
I have heard of the issues with #pragma once
before, but I have never seen them in practice. Certainly, if there is a compiler we need to target that does not support it then we should switch to the #ifdef
guards.
The reason I prefer #pragma once
is because on multiple occasions I have experienced developers copy and paste files without changing the previous unique string used for the #ifdef
. This results in nonsensical compiler errors that are nontrivial to find if unaware of the situation. So, I find the #pragma once
option to be less error-prone.
Thanks for the info.
As I was going through the code for CSR and particle_structure, I noticed that we use
#pragma
instead of standard include guards in most of these files. I'm not super familiar with#pragma
, so I looked it up and it seems that it's not portable to some older compilers and it has some issues with symbolic links to the same file. Does this matter to us?Here's a link to the Wikipedia page which provides some general information (including some portability version references), and here's a Microsoft Docs page that discusses some specifics about when to use/not to use
#pragma
.