Hi,
I'm trying to understand macro expansion, and am a bit stuck. I would like, 
in distilled form, to have a macro "@do_ccall" which calls its argument 
with Int type. Thus I would like

julia> macroexpand(:(@do_ccall(f,1,2,3)))
:(ccall(f,Int,(Int64,Int64,Int64),args...))

and I programmed it as
julia> macro do_ccall(f,args...) 
:(ccall(f,Int,$(ntuple(i->Int,length(args))),args...)) end
@do_ccall (macro with 1 method)

Now the tuple argument just doesn't seem to get interpreted properly:

julia> @do_ccall(C_NULL,1,2,3)
ERROR: syntax: ccall argument types must be a tuple; try "(T,)"
 in eval(::Module, ::Any) at ./boot.jl:237

(note: calling the routine at C_NULL would have crashed Julia; it's just 
for demonstration purposes)

Thanks in advance! Laurent

Reply via email to