-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Zig Support #2471
Comments
See #2086. |
Wow! Interesting hope it gets merged. This would lessen the high demands of immediately attaching new languages to the project. I've been reading the manual for this fork, seems to meet the trivial requirements. Edit Reading PR comments one can see some impediments about the fork. 😕 |
Nice, building the latest version of SWIG with Zig (cc/c++ [clang wrapper]), probably helps with cross-compiling. $> ~/Swig/bin/swig -version
SWIG Version 4.2.0
Compiled with zig c++ -fno-sanitize=all -target x86_64-linux-musl -lc++ [x86_64-pc-linux-musl]
Configured options: -pcre
Please see https://www.swig.org for reporting bugs and further information |
Is it possible for Swig to generate C header instead of putting declarations in Go directly? @ojwb |
Not sure why you're asking me that, but anyway, that's already been answered above - that's what the C target language in #2086 does. The conclusion here seems to be that Zig can wrap a C API automatically so having a full Zig target language isn't worth the time and effort to implement and maintain - better to put that effort into actually getting the C target language merged. Hence closing. |
Yes, it might not be worth adding another language to the list like so many others. I asked him because of his feedback regarding golang support in Swig. I believe it would be interesting for the |
@kassane, I would avoid using the SWIG Go module as a basis for any other language like Zig, or use it for any purpose other than for only Go wrappers. This is because the Go module is fundamentally flawed and when fixed is likely to change quite a lot and quite possibly in a non-backwards compatible manner, see #2337. If the C language module was designed for use as a basis for other target languages, then you could build Zig wrappers on top of it. But it isn't. It's actually quite unclear what the design goals of it are as it is currently poorly documented. Nevertheless, the standard approach to writing new SWIG language modules is to take another existing similar (mature) language module and tweak it for the new target language and this is what I suggest is still done for any new language. |
@wsfulton I don't think the idea here is about building a new SWIG target language on the C target language (at least that's not what I was talking about). AIUI, Zig can automatically wrap a C API but not a C++ API. With a SWIG C target language one could wrap a C++ API to a C one, then point Zig at that C API to allow using a C++ library from Zig. |
HomePage: https://ziglang.org
Zig and its easy interoperability with C(89). However there is no indication of supporting C++ directly.
I experimented with SWIG 4.x today and used the example of exporting
List<T>
to Go and took advantage of the conversion and ported it to Zig and used built-in header declaration in Go (example) inexample.h
file and also usedzig translate-c
convert C to Zig (although it is not demanding when I can just use@cImport(@cInclude("example.h"));
).And it worked normally! However SWIG does not target the C++ to C language.
C++ - List impl
Zig - preview code
Cleaned code (refactored):
Would it be helpful to have if not another programming language as zig in the list like every other language, or to just have the C language on the target too?
The text was updated successfully, but these errors were encountered: