As macros work on expressions, you will need to insert the variables – and not just their names as in your for loop – into the expression generated by the macro. Thus, instead of generating a for loop – which would then run when executed – you could unroll the loop and generate the desired calls to println directly, i.e., here is a working macro for your minimal example:
macro showvars(vars...)
unrolled = [:(println("$($(QuoteNode(v))) = ", $(esc(v)))) for v in vars]
quote
$(unrolled...)
end
end
When writing macros it helps a lot to check the expansion, i.e.,
julia> @macroexpand1 @showvars c a
quote
#= REPL[72]:4 =#
Main.println("$(:c) = ", c)
Main.println("$(:a) = ", a)
end