zig icon indicating copy to clipboard operation
zig copied to clipboard

unable to translate macro: undefined identifier `__extension__`

Open flyfish30 opened this issue 1 year ago • 1 comments

Zig Version

0.11

Steps to Reproduce and Observed Behavior

  1. Create a new ext-fail directory, and then cd to this directory, run command "zig init-exe".
  2. Delete the file src/main.zig, create a new main.zig with bellow source code:
const std = @import("std");

const c = @cImport(
    @cInclude("arm_neon.h"),
);

pub fn main() !void {
    var arr: [128]u32 = undefined;
    var i: usize = 0;
    while (i < arr.len) : (i += 1) {
        arr[i] = @rem(@as(u32, @intCast(i)), 23) + 30;
    }

    const vec4x4 = loadVec4x4U32(&arr);
    std.debug.print("load vec4x4: {any}\n", .{vec4x4});
}

fn loadVec4x4U32(ptr: [*]u32) @Vector(16, u32) {
    return c.vld4q_u32(ptr);
}

  1. Run command "zig build -fqemu -Dtarget=aarch64-linux", the compiler output a error message in bellow:

zig build-exe ext-fail Debug aarch64-linux: error: the following command failed with 1 compilation errors: /usr/local/Cellar/zig/0.11.0/bin/zig build-exe /Users/liuchangsheng/myproject/Zig/ext-fail/src/main.zig --cache-dir /Users/liuchangsheng/myproject/Zig/ext-fail/zig-cache --global-cache-dir /Users/liuchangsheng/.cache/zig --name ext-fail -target aarch64-linux -mcpu generic --listen=- Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none) install transitive failure └─ install ext-fail transitive failure └─ zig build-exe ext-fail Debug aarch64-linux 1 errors /Users/liuchangsheng/myproject/Zig/ext-fail/zig-cache/o/206f2d99c9cf014e18b9f2219aa57989/cimport.zig:15207:23: error: unable to translate macro: undefined identifier __extension__ pub const vld4q_u32 = @compileError("unable to translate macro: undefined identifier __extension__"); // /usr/local/Cellar/zig/0.11.0/lib/zig/include/arm_neon.h:12936:9 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ referenced by: loadVec4x4U32: src/main.zig:19:13 main: src/main.zig:14:20 remaining reference traces hidden; use '-freference-trace' to see all reference traces

Expected Behavior

The zig should success to compile this main.zig file, and then build a exe file that can run in arm64 linux.

flyfish30 avatar Feb 08 '24 07:02 flyfish30