Skip to content

Question: How to handle a **char parameter that was mapped to a ptr cstring? #163

@tech4rd

Description

@tech4rd

First and foremost, thanks for the library. As a Nim newbie this has helped me wrapping the GLFW and OpenGL libraries.

Second, if this is not the best place to ask questions, please let me know and I will redirect it elsewhere.

I have several small hiccups while doing experiments. This one is for wrapping the openGL function glShaderSource. The string represents an array of strings. I was assuming that a cstringArray would be the equivalent type. However when I compile:

  var vertexShader = glCreateShader(GL_VERTEX_SHADER)
  var vertexShaderTextArr : array[0..0,cstring] = [cstring(vertexShaderText)]
  var xx: cstringArray = cast[cstringArray](vertexShaderTextArr.addr)
  var zero: GLint_typedef = 0 
  glShaderSource(vertexShader, GLsizei(1),
                xx, zero.addr)

I get the compilation error:

Error: type mismatch: got <GLuint_587203219, GLsizei, cstringArray, ptr GLint_typedef>
        ... but expected one of:
        ... PFNGLSHADERSOURCEPROC_587204782 = proc (a0: GLuint_587203219, a1: GLsizei_587203223, a2: ptr cstring, a3: ptr GLint_typedef_587203217){.cdecl.}

So a2 is a ptr cstring, which I assume is compatible to a **char. But why is cstringArraynot used? How should one deal with arrays of C strings in Fuhtark?

TIA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions