Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build-lib emitted headers should be able to depend on system includes #2232

Open
daurnimator opened this issue Apr 10, 2019 · 2 comments
Open
Labels
use case Describes a real use case that is difficult or impossible, but does not propose a solution. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@daurnimator
Copy link
Contributor

const std = @import("std");

const lua = @cImport({
    @cInclude("lua.h");
    @cInclude("lauxlib.h");
});

export fn luaopen_mylib(L: *lua.lua_State) c_int {
    return 0;
}
zig build-lib -dynamic --library c -isystem /usr/include/ src/main.zig

The output .h file contains:

#ifndef MAIN_H
#define MAIN_H


#ifdef __cplusplus
#define MAIN_EXTERN_C extern "C"
#else
#define MAIN_EXTERN_C
#endif

#if defined(_WIN32)
#define MAIN_EXPORT MAIN_EXTERN_C __declspec(dllimport)
#else
#define MAIN_EXPORT MAIN_EXTERN_C __attribute__((visibility ("default")))
#endif

struct struct_lua_State;

MAIN_EXPORT int luaopen_mylib(struct struct_lua_State * L);

#endif

This defines the opaque type struct struct_lua_State, when it needs to #include <lua.h> and use the existing opaque type lua_State.

@andrewrk
Copy link
Member

Related: #2041

@andrewrk andrewrk added this to the 0.5.0 milestone Apr 10, 2019
@andrewrk andrewrk added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Apr 10, 2019
@andrewrk
Copy link
Member

This issue is what @tiehuis proposed in #2041 (comment)

@andrewrk andrewrk added the zig build system std.Build, the build runner, `zig build` subcommand, package management label Sep 20, 2019
@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Sep 20, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Jan 7, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 27, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 May 19, 2021
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 Nov 23, 2021
@andrewrk andrewrk modified the milestones: 0.10.0, 0.11.0 Apr 16, 2022
@andrewrk andrewrk modified the milestones: 0.11.0, 0.12.0 Jun 19, 2023
@andrewrk andrewrk added use case Describes a real use case that is difficult or impossible, but does not propose a solution. and removed proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. labels Jul 26, 2024
@andrewrk andrewrk modified the milestones: 0.14.0, 0.16.0 Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
use case Describes a real use case that is difficult or impossible, but does not propose a solution. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

No branches or pull requests

2 participants