replace pragma once with include guards
When attempting to compile src/main.c with TCC (the Tiny C Compiler), I am getting the following errors:
In file included from main.c:1: In file included from c:/tcc/include/clap/all.h:3: In file included from c:/tcc/include/clap/clap.h:30: In file included from c:/tcc/include/clap/factory/plugin-factory.h:3: In file included from c:/tcc/include/clap/factory/../plugin.h:4: In file included from c:/tcc/include/clap/factory/../host.h:3: c:/tcc/include/clap/factory/../version.h:14: error: struct/union/enum already defined
As pragma once is a non-standard C extension, I feel using include guards will help with cross-compiler compatibility.
Oh gosh do we use pragma once here?
You are totally correct it is non standard and we should replace it everywhere it is used
I have a script that does that. Let me talk with my collaborators in clap land about how and when to stage
And thank you for reporting this!
Why not fix tcc instead?
It is probably a similar effort to fix tcc and add the old school header guard.
I'm against the old header guard.
It must not be difficult, open tcc source code, find the preprocessor, it must have a hash table somewhere: macro name to definition, then just put next to it a hash set and impl #pragma once.
Can you elaborate on why you don't prefer include guards? I personally don't see them as a problem.
The TCC source code seems to imply that there is support for pragma once:
https://github.com/TinyCC/tinycc/blob/2d4e4a69c44b7646ad62fa5f4eae6e88f92878a9/tcc.h#L1301
I just built the fork of TCC that is on GitHub, and I was able to compile src/main.c without any problems. I was previously using the last official release of TCC from 2017, and it appears that version doesn't support pragma once.
Ugh I hate us not obeying the published standard
But that’s why we have multiple voices who decide!
Can we update the readme to say we are not standard c++ or c99 instead of fixing the pragma?