Less hacky, maybe to your taste:
julia> ccaller(fun, retT, argT, args...) = ccaller(Val(fun), retT, argT, args...)
ccaller(fun::Val, retT, argT, args...) = ccaller(fun, retT, Tuple{argT...}, args...)
@generated ccaller(::Val{fun}, ::Type{retT}, ::Type{argT}, args...) where {fun, retT, argT<:Tuple} = let;
length(argT.parameters) == length(args) || error("bruh not cool")
quote @ccall $fun($((:(args[$i]::$(argT.parameters[i])) for i=1:length(args))...))::$retT end
end
ccaller (generic function with 4 methods)
julia> ccaller(:pow, Cdouble, (Cdouble,Cdouble), 2, 10)
1024.0
Splattable:
julia> ccaller(:pow, Cdouble, ((Cdouble,Cdouble)...,), (2, 10)...)
1024.0