@cImport: pub const vs pub usingnamespace?

In various programs I often see @cImport done two different ways:

pub usingnamespace @cImport({
    @cInclude("somefoo.h");
});
pub const c = @cImport({
    @cInclude("somefoo.h");
});

What are the upsides/downsides of the two different methods and which one should I probably default to?

Thanks.

Personally, I think usingnamespace should be avoided whenever possible.
For details, see this open proposal to remove it:

Also, note this accepted proposal to move @cImport to the build system:

4 Likes

Typically you should import as a const because it makes it obvious where the functions come from

3 Likes