# Ccall: how to wrap call-by-reference C functions?

**URL:** https://discourse.julialang.org/t/ccall-how-to-wrap-call-by-reference-c-functions/53510
**Category:** General Usage
**Created:** [January 18, 2021, 1:14am UTC](https://discourse.julialang.org/t/ccall-how-to-wrap-call-by-reference-c-functions/53510 "2021-01-18T01:14:23Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [January 18, 2021, 1:33am UTC](https://discourse.julialang.org/t/ccall-how-to-wrap-call-by-reference-c-functions/53510/2 "2021-01-18T01:33:40Z")

</div>

> [@simon-anders](#):
>
> Which type should `a` have

The one you declare you’re passing to the C function, `Ref{Cint}`. Note that `Cint` is an alias for `Int32`, but integer literals on a 64-bit Julia are `Int64`

```julia
julia> a = Ref{Cint}(13)
Base.RefValue{Int32}(13)

julia> ccall((:put_7, "./libptrtest.so"), Cvoid, (Ref{Cint},), a)

julia> a
Base.RefValue{Int32}(7)

julia> a[]
7

```

For reference, see the relevant section of the manual: [Passing Pointers for Modifying Inputs](https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/index.html#Passing-Pointers-for-Modifying-Inputs)

---

_[View the full topic](https://discourse.julialang.org/t/ccall-how-to-wrap-call-by-reference-c-functions/53510)._
