# Is it possible to splat into ccall?

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-splat-into-ccall/95761>\
**Category:** General Usage\
**Tags:** ccall\
**Created:** [March 8, 2023, 7:49pm UTC](https://discourse.julialang.org/t/is-it-possible-to-splat-into-ccall/95761 "2023-03-08T19:49:46Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![lmtzx9h4qqnt](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@lmtzx9h4qqnt](https://discourse.julialang.org/u/lmtzx9h4qqnt)\
**Post date:** [March 10, 2023, 7:47pm UTC](https://discourse.julialang.org/t/is-it-possible-to-splat-into-ccall/95761/21 "2023-03-10T19:47:44Z")

</div>

No, that’s all understood. For some reason, I just got the idea at some point that `@ccall` defers to `ccall` (instead of making an `Expr(:foreigncall)` directly). Perhaps because of statements like these:

> [@Why is ccall syntax?](https://discourse.julialang.org/t/why-is-ccall-syntax/72427/3):
>
> `@ccall` is a more recent and much more attractive syntax for the same thing which doesn’t need special support from the parser or lowering.

> [@Sukera](#):
>
> Like I said, `@ccall` is the same as `ccall`, just in macro form.

But they’re not the same! `@ccall` can call varargs functions with arbitrary (mixed) types, whereas varargs arguments must all be of the same type with `ccall`. These are equivalent:

```julia
julia> ccall(:printf, Cint, (Cstring, Cint...), "%d %d %d\n", 1, 2, 3);
1 2 3

julia> @ccall printf("%d %d %d\n"::Cstring; 1::Cint, 2::Cint, 3::Cint)::Cint;
1 2 3

```

But there’s no way to express the following using `ccall`:

```julia
julia> @ccall printf("%d %f %s\n"::Cstring; 1::Cint, 2.0::Cdouble, "abc"::Cstring)::Cint;
1 2.000000 abc

```

([This is also stated in the documentation.](https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/#man-bits-types))

**Edited to add:** I just realized there does seem to be one thing that `ccall` can do and `@ccall` can’t, which is specifying a calling convention? (Seems to be hard-coded to `:ccall`, if I understand the code correctly.) Should be straightforward to add, but it’s not in the current implementation.

---

_[View the full topic](https://discourse.julialang.org/t/is-it-possible-to-splat-into-ccall/95761)._
