On Sat, May 16, 2015 at 5:01 PM, andrew cooke <[email protected]> wrote:
>
> Does anyone have a working example that calls printf via llvmcall?
>
> I realise I'm uncomfortably inbetween llvmdev and julia-users, but I'm
> asking here first because I suspect my limitations are still more
> julia-related.
>
> In particular,
>
> julia> g() = Base.llvmcall("""
> call i32 (i8*, ...)* @printf(i8* c"hello world\00")
> ret""",
> Void, Tuple{})
> g (generic function with 2 methods)
>
> julia> g()
> ERROR: error compiling g: Failed to parse LLVM Assembly:
> julia: llvmcall:3:35: error: expected string
> call i32 (i8*, ...)* @printf(i8* c"hello world
> ^
>
> seems like it's *almost* there...?
>
> Thanks,
> Andrew
>
> (I suspect I also need something other than @printf, like
> IntrinsicsX86.printf or something, but I can't find where I saw an example
> like that... Related, declare doesn't seem to be accepted, or assignment to
> global vsariables. But I am completely new to all this...)
>
I was also interested in knowning how to use `llvmcall` in general but
at least for this limited case, (and I guess you probably know
already) it is easier to user `ccall`
```julia
julia> ccall(:printf, Int, (Ptr{Cchar},), "hellow world\n")
hellow world
13
```