I've gotten passed that issue (at least on OSX) and am now facing a new issue. 
Please see this gist for a run down of what's going on -

[https://gist.github.com/zacharycarter/de596b1968b63f2e0967d41b31b73804](https://gist.github.com/zacharycarter/de596b1968b63f2e0967d41b31b73804)
    
    
    void nk_convert(const struct nk_convert_config *config)
    {
        printf("%d\n", config->vertex_layout[0].attribute);
    }
    
    

is printing 
    
    
    1536
    

The relevant nim code -
    
    
    {.compile: "test.c".}
    
    type nk_size = culong
    
    type
      nk_draw_vertex_layout_attribute* = enum
        NK_VERTEX_POSITION, NK_VERTEX_COLOR, NK_VERTEX_TEXCOORD,
        NK_VERTEX_ATTRIBUTE_COUNT
    
    type
      nk_draw_vertex_layout_format* = enum
        NK_FORMAT_SCHAR, NK_FORMAT_SSHORT, NK_FORMAT_SINT, NK_FORMAT_UCHAR,
        NK_FORMAT_USHORT, NK_FORMAT_UINT, NK_FORMAT_FLOAT, NK_FORMAT_DOUBLE,
        NK_FORMAT_COLOR_BEGIN, NK_FORMAT_R16G15B16, NK_FORMAT_R32G32B32,
        NK_FORMAT_R8G8B8A8, NK_FORMAT_R16G15B16A16, NK_FORMAT_R32G32B32A32,
        NK_FORMAT_R32G32B32A32_FLOAT, NK_FORMAT_R32G32B32A32_DOUBLE, 
NK_FORMAT_RGB32,
        NK_FORMAT_RGBA32, NK_FORMAT_COUNT
    
    type
      nk_draw_vertex_layout_element* = object
        attribute*: nk_draw_vertex_layout_attribute
        format*: nk_draw_vertex_layout_format
        offset*: nk_size
    
    type
      nk_convert_config* = object
        vertex_layout*: ptr nk_draw_vertex_layout_element
    
    proc nk_convert*(a6: ptr nk_convert_config) {.cdecl, importc: "nk_convert".}
    
    type nk_byte* = cuchar
    
    template offsetof(typ, field): expr = (var dummy: typ; 
cast[uint](addr(dummy.field)) - cast[uint](addr(dummy)))
    
    type
      nk_glfw_vertex = object
        position: array[2, float]
        uv: array[2, float]
        col: array[4, nk_byte]
    
    var config = nk_convert_config()
    
    var vertex_layout {.global.} = @[
      nk_draw_vertex_layout_element(
        attribute: NK_VERTEX_POSITION,
        format: NK_FORMAT_FLOAT,
        offset: offsetof(nk_glfw_vertex, position)
      ),
      nk_draw_vertex_layout_element(
        attribute: NK_VERTEX_TEXCOORD,
        format: NK_FORMAT_FLOAT,
        offset: offsetof(nk_glfw_vertex, uv)
      ),
      nk_draw_vertex_layout_element(
        attribute: NK_VERTEX_COLOR,
        format: NK_FORMAT_FLOAT,
        offset: offsetof(nk_glfw_vertex, col)
      ),
      nk_draw_vertex_layout_element(
        attribute: NK_VERTEX_ATTRIBUTE_COUNT,
        format: NK_FORMAT_COUNT,
        offset: 0
      )
    ]
    
    config.vertex_layout = addr vertex_layout[0]
    
    nk_convert(addr config)
    

Reply via email to