Error when using @cfunction

The following code addVerticalSlider = @cfunction( $_addVerticalSlider, Cvoid, (Ptr{Cvoid}, Cstring, Ptr{T}, T, T, T, T)) gives ERROR: TypeError: in cfunction method definition, expected Type, got a value of type TypeVar on Julia 1.9. It was working with older version (like 1.6).

I can use real types instead of T , but Ptr{T} works… Why that? How can it be solved ?

What is T in your example? Can you share a MWE that people on this forum can reproduce locally, to diagnose the issue?

In the initGlue! function here: https://github.com/sletz/Faust.jl/blob/main/src/uiglue.jl, so this Faust.jl package. Is this enough ?

Ah, I see - I don’t think you can use @cfunction like that in local scope. The function in question must already exist, and the argument types need to be known. As the docstring mentions, all of this happens during compilation, not runtime:

Note that the argument type tuple must be a literal tuple, and not a tuple-valued variable or expression (although it can include a splat expression). And that these arguments will be evaluated in global scope during compile-time (not deferred until runtime).

But then:

  • why does the Ptr{T} work in the first place (since it is also using a TypeVar T)
  • Is was working with 1.6, why has this been changed ?