Search code examples
libpqzig

How to create a type '[*c]const [*c]const u8' for paramValues of PQexecParams


I'm trying to use the libpq library in zig. I'm trying to pass paramValues to PQexecParams. I'm just not sure how to create the required type.

The type required by the documentation is:

const char * const *paramValues

So something like:

const char data[2][2] = {"12","me"};

If do something like this in zig:

const paramValues = [_][]const u8 {"12","me"};

I get this error:

error: expected type '[*c]const [*c]const u8', found '[2][]const u8'

Solution

  • Use:

        const paramValues = [_][*:0]const u8 {"12","me"};
    
        PQexecParams(....., &paramValues, ....);