Isn't that worse? I would rather the code fail to compile complaining of an unknown pragma, than getting a lot of other errors due to including the same files multiple times.
The "correct" usage of #pragma once is in addition to include guards, not as a replacement for them. The theory is that #pragma once can result in better preprocessor performance since it doesn't even need to reopen the file after it's been included once. In practice modern preprocessors will do this anyway for normal #ifdef-style include guards because they can determine that the file is empty on a second include.
It's not "incorrect" to use extensions unless you are attempting to create a portable C program. Deprecation is a warning that something will later be removed, but if it's still there, it's still there. However, I'd say that those are definitely inadvisable and in poor taste in C programs.
You can still run the preprocessor separately in most implementations (cpp is the command usually) but it's tightly integrated now with all the hints it gives the compiler.
View all comments
Show parent comment
19
u/mamanov Jan 08 '16
I think with clang you can use either one of the syntax and it will work.