OpenGL has a function for compiling shader source code. It takes an array of strings, a.k.a. const char**. I can see an example in ModernGL.jl of how to do this with pointers:
However, my understanding is that Ptr is dangerous compared to the more modern Ref. The docs say that Ref{Any} is a special case that provides a reference to a reference, but in practice it doesn’t seem to work when I make the ccall with Ref{Any}(source).
What is the best-practice way to pass a nested pointer into a ccall?
I have created a demo for this, feel free if you have any questions!
Any is a Julia specific container that is capable of holding any Julia value, just like void * in C. Generally, this is used to pass extra arguments to C functions, which will eventually be used by a Julia function. This blog post demonstrates the typical use case. As Julia objects are far more complicated than simple pointers, this is not equivalent to a reference or pointer.
FWIW, in LIKWID.jl I had to wrap a C API and in a few cases, a reference to a char** was required as input on the C side (to realize multiple string outputs). In the ccall I have Ptr{Ptr{Ptr{Cchar}}} for the input argument and to call it, I create and pass over a Ref{Ptr{Ptr{Cchar}}}(). Later, I use unsafe_wrap to get the strings.