Translate C failure after upgrade to 0.16

Code translation was working just fine in 0.15.2 using the b.addTranslateC step. After upgrading to 0.16, I’m now getting wall of issues from glib:

error: translation failure
/usr/include/glib-2.0//glib/gutils.h:327:1: error: unknown type name 'pragma'
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
^
/usr/include/glib-2.0//glib/gmacros.h:757:39: note: expanded from here
  _Pragma ("GCC diagnostic push")   
                                      ^
<scratch space>:74:2: note: expanded from here
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 ^
/usr/include/glib-2.0//glib/gutils.h:327:1: error: expected ';', found 'an identifier'
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
^
/usr/include/glib-2.0//glib/gmacros.h:757:39: note: expanded from here
  _Pragma ("GCC diagnostic push")   
                                      ^
<scratch space>:74:13: note: expanded from here
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

ad nauseum

I didn’t change anything with the translate C step

Build.zig

    const deps = b.addTranslateC(.{
        .root_source_file = b.path("c-deps.h"),
        .target = target,
        .optimize = optimize,
    });
    deps.addSystemIncludePath(.{ .cwd_relative = "/usr/include/gdk-pixbuf-2.0/" });
    deps.addSystemIncludePath(.{ .cwd_relative = "/usr/include/glib-2.0/" });
    deps.addSystemIncludePath(.{ .cwd_relative = "/usr/lib64/glib-2.0/include/" });
    deps.addSystemIncludePath(.{ .cwd_relative = "/usr/include/cairo/" });

header file:

#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

What am I missing?

arocc is likely just not adding #defs it should be.

If you can figure out what those are, you can look for or make an issue since it is certainly a bug as it is supposed to be a drop-in replacement.

1 Like

That was what I thought as well. I think I found an issue related to it: https://codeberg.org/ziglang/translate-c/issues/328

I’ll have to wait for that to be resolved. (Or if I have time try to contribute a fix if I can figure it out).

I think what changed was this:

Zig’s implementation of translate-c is now based on arocc and translate-c instead of libclang.

1 Like

Yes, so what the situation now is working out all the implicit assumptions, accrued dependencies, and idiosyncratic accumulated cruft of two different implementatons of something we hoped was “standard” (C)

AKA ideal theory versus reality.

So, stuff comes up :slight_smile:

4 Likes