Add standard header guards alongside #pragma once#483
Add standard header guards alongside #pragma once#483vmednis wants to merge 1 commit intofree-audio:mainfrom
Conversation
|
Is there an issue for Zig not supporting |
|
Similar issues with No issue currently exists for this in Zig; however, in my own testing, including the headers from Zig using const clap = @cImport({
@cInclude("/.../clap/include/clap/clap.h");
});
const expect = @import("std").testing.expect;
test "check if include was successful" {
const version: clap.clap_version = clap.CLAP_VERSION;
try expect(version.major == 1);
try expect(version.minor == 2);
try expect(version.revision == 7);
}The lack of |
|
I would personally be supportive of removing pragma once from all our codebases, just FYI alex. I agree that its not standard. |
|
It's not clear what it fixes, tcc now supports pragma once apparently, and zig did, it is just a temporary regression, which could be worked around by using the previous version until they fix it. I don't like traditional header guard, I think it is worse than I don't want to maintain this stuff, so if it gets out of sync or whatever, someone else will have to make a PR. |
#pragma onceis widely supported, but it is not part of the C standard and not all C toolchains recognize it. To improve portability, this adds traditional include guards alongside the existing#pragma once.I ran into issues using the headers in a Zig project with
@cInclude, which were resolved after adding the guards. Similar problems have been reported with older versions of TCC (Fixes #466).#pragma onceis kept to preserve existing behavior and potential compile-time benefits on compilers that support it.These changes don’t affect the ABI or public API and only make header inclusion more reliable across different toolchains.