# Problem with \`@dlsym\` (from the manual) for calling C

**URL:** <https://discourse.julialang.org/t/problem-with-dlsym-from-the-manual-for-calling-c/51403>\
**Category:** New to Julia\
**Created:** [December 7, 2020, 2:04pm UTC](https://discourse.julialang.org/t/problem-with-dlsym-from-the-manual-for-calling-c/51403 "2020-12-07T14:04:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg9q](https://avatars.discourse-cdn.com/v4/letter/g/e79b87/32.png) [@greg9q](https://discourse.julialang.org/u/greg9q)\
**Post date:** [December 7, 2020, 2:04pm UTC](https://discourse.julialang.org/t/problem-with-dlsym-from-the-manual-for-calling-c/51403/1 "2020-12-07T14:04:40Z")

</div>

The manual’s “Calling C and Fortran Code \> Indirect Calls” section provides the following macro to allow using a non-constant function spec with `ccall`:

```julia
macro dlsym(func, lib)
    z = Ref{Ptr{Cvoid}}(C_NULL)
    quote
        let zlocal = $z[]
            if zlocal == C_NULL
                zlocal = dlsym($(esc(lib))::Ptr{Cvoid}, $(esc(func)))::Ptr{Cvoid}
                $z[] = $zlocal
            end
            zlocal
        end
    end
end

```

When I tried using it I got an error:

```julia
ERROR: LoadError: LoadError: LoadError: UndefVarError: zlocal not defined

```

I’m just getting started with Julia and have barely ventured into macros but I think the fix `$z[] = zlocal` is needed. Is this just a typo in the manual?
