Issues importing C libraries through new method (translate-c build module)

I am trying to migrate my fork of the Thanatos project over to version 0.16.0 and wanted to future-proof it by removing the use of @cImport and migrating in accordance with the 0.16 release notes recommendation.
Importing sqlite3 works fine this way, but importing gtk runs into this issue.

Error before importing:

src/webview.zig:41:14: error: root source file struct 'c' has no member named 'gtk_init'
        _ = c.gtk_init(null, null);

After importing (include <gtk/gtk.h>)

/nix/store/fl75ki4bwr8lj8w63c1yr4v3np177sv7-gtk+3-3.24.52-dev/include/gtk-3.0/gtk/gtk-autocleanups.h:204:1: error: expected ';', found 'an identifier'
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWidgetPath, gtk_widget_path_unref)
...
/nix/store/fl75ki4bwr8lj8w63c1yr4v3np177sv7-gtk+3-3.24.52-dev/include/gtk-3.0/gtk/gtk-autocleanups.h:204:1: error: unknown type name 'diagnostic'
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWidgetPath, gtk_widget_path_unref)
...

There are many more errors like this and in total it encounters:

error: 5926 compilation errors

All of these errors seem to do with c macros being improperly translated, but there are far too many for me to read through as it takes up the entire scrollable height of my terminal. Any help would be appreciated

Here is a pastebin to my build.zig as well build.zig for Thanatos Fork on 0.16.0 - Pastebin.com

Your error seems to be an issue with macro expansion. With 0.16.0, Zig switched to using arocc for c translation.

I recently got a patch merged into arocc that might address this issue. However, we will have to wait until ziglang updates it’s fork of arocc and then updates translate-c to use the updated fork. This may take a while. You may have to stay on 0.15.2 until that is handled.

1 Like

I believe installing the newly-patched arocc directly and configuring your build to use that specific install should also work? I think I read that in recent release notes.

1 Like

Yes, that will work if the fix has been added. This is a way to work around it, but you will have to set up the full overried.

1 Like

Thank you so much! I will try that method out soon.