Search code examples
javac++cjna

What does const char*** mean and how does it translate from C to Java?


I am using JNA to write a Java interface for a C++ written DLL for control of a small device.

While translating data types I came across

const char*** someVariable

Can someone please explain to me what this means and how can it be recreated in Java?

I have read up on pointers and I am using the JNA documentation to map C++ types to Java but I cannot find a reference to a type with three asterisks at the end.

Should this be interpreted as a pointer to a String array?


Solution

  • if you know the concept of pointers,

    const char*** means it is a triple pointer, so you can think of it this way:

    const char***--->const char**--->const char*--->const char
    

    So yes it can be interpreted as a pointer to a string array, because a string array can be interpreted as a double pointer.

    let's say a is an array of strings:

    const char *a[15];
    

    In this case **a would give you the first char of the first string in a.

    you can declare:

    const char ***b = &a;
    

    in this case ***b would give you the first char of the first string in a.