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

translate-c: handle string concatenation of function calls #19355

Closed
willnode opened this issue Mar 19, 2024 · 1 comment · Fixed by #19439
Closed

translate-c: handle string concatenation of function calls #19355

willnode opened this issue Mar 19, 2024 · 1 comment · Fixed by #19439
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. translate-c C to Zig source translation feature (@cImport)
Milestone

Comments

@willnode
Copy link

Zig Version

0.12.0-dev.3366+8e7d9afda

Steps to Reproduce and Observed Behavior

# See https://github.com/willnode/summon/tree/a246528
git clone https://github.com/willnode/summon.git -b try-zig
cd summon
make install-nginx
zig build
install
└─ install summon
   └─ zig build-lib summon Debug native 3 errors
/home/willnode/summon/zig-cache/o/9f471bc5f7934470be5987871f47d714/cimport.zig:4488:11: error: opaque types have unknown size and therefore cannot be directly embedded in structs
    file: ngx_file_t = @import("std").mem.zeroes(ngx_file_t),
          ^~~~~~~~~~
/home/willnode/summon/zig-cache/o/9f471bc5f7934470be5987871f47d714/cimport.zig:3047:31: note: opaque declared here
pub const struct_ngx_file_s = opaque {};
                              ^~~~~~~~~
/home/willnode/summon/zig-cache/o/9f471bc5f7934470be5987871f47d714/cimport.zig:5842:36: error: unable to translate C expr: unexpected token 'a string literal'
pub const NGX_MODULE_SIGNATURE_0 = @compileError("unable to translate C expr: unexpected token 'a string literal'"); // /home/willnode/summon/nginx-1.22.1/src/core/ngx_module.h:21:9
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.zig:24:13: error: non-extern variable with opaque type 'cimport.struct_ngx_buf_s'
    var b: c.ngx_buf_t = undefined;
           ~^~~~~~~~~~
/home/willnode/summon/zig-cache/o/9f471bc5f7934470be5987871f47d714/cimport.zig:3049:30: note: opaque declared here
pub const struct_ngx_buf_s = opaque {};
                             ^~~~~~~~~
error: the following command failed with 3 compilation errors:
/home/willnode/.local/opt/zig-v0.12.0-dev.3366+8e7d9afda/zig build-lib -ODebug -I /home/willnode/summon/nginx-1.22.1/objs -I /home/willnode/summon/nginx-1.22.1/src/mail -I /home/willnode/summon/nginx-1.22.1/src/os/unix -I /home/willnode/summon/nginx-1.22.1/src/os -I /home/willnode/summon/nginx-1.22.1/src/event/modules -I /home/willnode/summon/nginx-1.22.1/src/event -I /home/willnode/summon/nginx-1.22.1/src/stream -I /home/willnode/summon/nginx-1.22.1/src/http/v2 -I /home/willnode/summon/nginx-1.22.1/src/http/modules/perl -I /home/willnode/summon/nginx-1.22.1/src/http/modules -I /home/willnode/summon/nginx-1.22.1/src/http -I /home/willnode/summon/nginx-1.22.1/src/core -I /home/willnode/summon/nginx-1.22.1/src/misc -I /home/willnode/summon/nginx-1.22.1/objs/src/mail -I /home/willnode/summon/nginx-1.22.1/objs/src/os/unix -I /home/willnode/summon/nginx-1.22.1/objs/src/os -I /home/willnode/summon/nginx-1.22.1/objs/src/event/modules -I /home/willnode/summon/nginx-1.22.1/objs/src/event -I /home/willnode/summon/nginx-1.22.1/objs/src/stream -I /home/willnode/summon/nginx-1.22.1/objs/src/http/v2 -I /home/willnode/summon/nginx-1.22.1/objs/src/http/modules/perl -I /home/willnode/summon/nginx-1.22.1/objs/src/http/modules -I /home/willnode/summon/nginx-1.22.1/objs/src/http -I /home/willnode/summon/nginx-1.22.1/objs/src/core -I /home/willnode/summon/nginx-1.22.1/objs/src/misc -Mroot=/home/willnode/summon/src/main.zig -lc --cache-dir /home/willnode/summon/zig-cache --global-cache-dir /home/willnode/.cache/zig --name summon -dynamic --listen=- 
Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install summon transitive failure
   └─ zig build-lib summon Debug native 3 errors
error: the following build command failed with exit code 1:
/home/willnode/summon/zig-cache/o/a9ce6dcf4254ec6f5921d0f7e1cffe37/build /home/willnode/.local/opt/zig-v0.12.0-dev.3366+8e7d9afda/zig /home/willnode/summon /home/willnode/summon/zig-cache /home/willnode/.cache/zig --seed 0x1b9ba675 -Z53dd1933cc77c915

Expected Behavior

Library should be successfully compiled

@willnode willnode added the bug Observed behavior contradicts documented or intended behavior label Mar 19, 2024
@Vexu
Copy link
Member

Vexu commented Mar 19, 2024

The first and third errors are #1499

The second reduces to a (somewhat) simple to implement missing feature:

#define bar() ""
#define FOO bar() "," bar()
// #define FOO bar "," bar

@Vexu Vexu added the translate-c C to Zig source translation feature (@cImport) label Mar 19, 2024
@Vexu Vexu added this to the 0.13.0 milestone Mar 19, 2024
@Vexu Vexu added the contributor friendly This issue is limited in scope and/or knowledge of Zig internals. label Mar 19, 2024
@Vexu Vexu changed the title cImport NGINX include headers failing: 3 compile errors on cImport translate-c: handle string concatenation of function calls Mar 19, 2024
@Vexu Vexu modified the milestones: 0.13.0, 0.12.0 Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. translate-c C to Zig source translation feature (@cImport)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants