# Doubt about using Clang.jl

**URL:** <https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599>\
**Category:** General Usage\
**Tags:** question, c, clang\
**Created:** [March 27, 2020, 1:44pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599 "2020-03-27T13:44:27Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![amCap1712](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amcap1712/32/13654_2.png) [@amCap1712](https://discourse.julialang.org/u/amCap1712)\
**Post date:** [March 27, 2020, 1:44pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/1 "2020-03-27T13:44:27Z")

</div>

I am trying to use to Clang.jl to parse header files for GNUAstro. GNUAstro has a dependency called wcslib. When I try to run the generated .jl file, I get the error that `wcsperm` is not defined. That makes sense because `wcsperm` is defined in `wcslib` header files not in GNUAstro. My question is how to fix this issue. In general, how to utilise structs and functions from dependencies ?

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [March 27, 2020, 1:59pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/2 "2020-03-27T13:59:33Z")

</div>

How did you build GNUAstro? If you use some compiler flags(e.g. -I/path/to/wcslib.h), you also need to pass them to Clang.jl. Specifically,

```julia
wc = init(; headers = LIBCLANG_HEADERS,
            output_file = joinpath(@ __DIR__ , "libclang_api.jl"),
            common_file = joinpath(@ __DIR__ , "libclang_common.jl"),
            clang_includes = vcat(LIBCLANG_INCLUDE, CLANG_INCLUDE),
            clang_args = ["-I", joinpath(LIBCLANG_INCLUDE, ".."), "-I", "/path/to/wcslib.h"],
            header_wrapped = (root, current)->root == current,
            header_library = x->"libclang",
            clang_diagnostics = true,
            )

```

---

<div class="post-metadata">

**Author:** ![amCap1712](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amcap1712/32/13654_2.png) [@amCap1712](https://discourse.julialang.org/u/amCap1712)\
**Post date:** [March 27, 2020, 2:04pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/3 "2020-03-27T14:04:32Z")

</div>

Ok, I’ll do that. Another thing, I want to ask is that many library like cfitsio and gsl already have julia wrappers. Is it possible or useful to use them while building this wrapper ?

---

<div class="post-metadata">

**Author:** ![amCap1712](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amcap1712/32/13654_2.png) [@amCap1712](https://discourse.julialang.org/u/amCap1712)\
**Post date:** [March 27, 2020, 2:09pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/4 "2020-03-27T14:09:58Z")

</div>

Here is my code:

```julia
using Clang

const LIBCLANG_INCLUDE = joinpath(@ __DIR__ , "gnuastro") |> normpath
const LIBCLANG_HEADERS = [joinpath(LIBCLANG_INCLUDE, header) for header in readdir(LIBCLANG_INCLUDE) if endswith(header, ".h")]

wc = init(; headers = LIBCLANG_HEADERS,
            output_file = joinpath(@ __DIR__ , "libgnuastro_api.jl"),
            common_file = joinpath(@ __DIR__ , "libgnuastro_common.jl"),
            clang_includes = vcat(LIBCLANG_INCLUDE, LIBCLANG_INCLUDE),
            clang_args = ["-I/usr/include", joinpath(LIBCLANG_INCLUDE, "..")],
            header_wrapped = (root, current)->root == current,
            header_library = x->"libgnuastro",
            clang_diagnostics = true,
            )

run(wc)

```

I am getting the following logs.

```julia
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/box.h:69:44: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/box.h:74:49: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/time.h:29:10: fatal error: 'stddef.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/pointer.h:52:38: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:54:1: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:58:36: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:62:41: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:41: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:51: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:64:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:67:39: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:70:43: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:50: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:74:29: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/qsort.h:135:3: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/sched.h:29:10: fatal error: 'stddef.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/arithmetic.h ...
┌ Warning: Skipping VarArg Function CLCursor (CLFunctionDecl) gal_arithmetic(int, int, int, ...)
└ @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:15
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/array.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/binary.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/blank.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/box.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/convolve.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/cosmology.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/data.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/dimension.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/eps.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/fits.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/git.h ...
┌ Warning: No Prototype for CLCursor (CLFunctionDecl) gal_git_describe() - assuming no arguments
└ @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:13
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/interpolate.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/jpeg.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/label.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/list.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/match.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/pdf.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/permutation.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/pointer.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/polygon.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/qsort.h ...
┌ Warning: not wrapping CLCursor (CLVarDecl) gal_qsort_index_single
└ @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:446
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/speclines.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/statistics.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/table.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/threads.h ...
┌ Warning: No Prototype for CLCursor (CLFunctionDecl) gal_threads_number() - assuming no arguments
└ @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:13
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/tiff.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/tile.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/txt.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/type.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/units.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/wcs.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl

```

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [March 27, 2020, 2:17pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/5 "2020-03-27T14:17:50Z")

</div>

I think it’s good to keep these wrappers orthogonal to each other. Library B depends on library A means that the implementation of B makes use of some public APIs of A, so only those binaries matter and this binary dependency problem has been solved by BB2. Clang.jl will search `wcslib`’s header files for certain types that are only defined there and directly map these types to basic Julia types, so there is no need to make `GNUAstro` depends on `wcslib`.

---

<div class="post-metadata">

**Author:** ![amCap1712](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amcap1712/32/13654_2.png) [@amCap1712](https://discourse.julialang.org/u/amCap1712)\
**Post date:** [March 27, 2020, 2:20pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/6 "2020-03-27T14:20:27Z")

</div>

Understood. Regarding the error log, is it normal or do I need to fix something?

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [March 27, 2020, 2:23pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/7 "2020-03-27T14:23:29Z")

</div>

These errors are basically clang errors, which means Clang.jl cannot correctly detect those system headers. For example, `/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found` means clang cannot found `stdio.h` in the path `/usr/include/stdio.h`.

```julia
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/box.h:69:44: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/box.h:74:49: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/time.h:29:10: fatal error: 'stddef.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/pointer.h:52:38: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:54:1: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:58:36: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:62:41: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:41: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:51: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:64:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:67:39: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:70:43: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:50: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:74:29: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/home/amcap1712/GNUAstro/gnuastro/qsort.h:135:3: error: unknown type name 'size_t'
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/sched.h:29:10: fatal error: 'stddef.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
warning: /home/amcap1712/GNUAstro/gnuastro/..: 'linker' input unused [-Wunused-command-line-argument]
/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found

```

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [March 27, 2020, 2:26pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/8 "2020-03-27T14:26:13Z")

</div>

> [@amCap1712](#):
>
> clang\_args = [“-I/usr/include”, joinpath(LIBCLANG\_INCLUDE, “…”)],

This doesn’t look right to me. It should be `clang_args = ["-I/usr/include", "-I", joinpath(LIBCLANG_INCLUDE, "..")],` and there is no need to add “-I/usr/include” except you’re working on macOS(in fact, one should use `args=["-I", joinpath(LIBCLANG_INCLUDE, ".."), map(x->"-I"*x, find_std_headers())...]` on Mojave+).

---

<div class="post-metadata">

**Author:** ![amCap1712](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amcap1712/32/13654_2.png) [@amCap1712](https://discourse.julialang.org/u/amCap1712)\
**Post date:** [March 27, 2020, 2:31pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/9 "2020-03-27T14:31:01Z")

</div>

I am on Ubuntu. I removed /usr/include. Now the line is `clang_args = ["-I", joinpath(LIBCLANG_INCLUDE, "..")],` . I still get the errors.

```julia
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/home/amcap1712/GNUAstro/gnuastro/box.h:69:44: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/box.h:74:49: error: unknown type name 'size_t'
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/time.h:29:10: fatal error: 'stddef.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/home/amcap1712/GNUAstro/gnuastro/pointer.h:52:38: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:54:1: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:58:36: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/pointer.h:62:41: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:41: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:61:51: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:64:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:67:39: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:70:43: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:73:50: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/polygon.h:74:29: error: unknown type name 'size_t'
/home/amcap1712/GNUAstro/gnuastro/qsort.h:135:3: error: unknown type name 'size_t'
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/sched.h:29:10: fatal error: 'stddef.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/limits.h:124:16: fatal error: 'limits.h' file not found
/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/arithmetic.h ...
┌ Warning: Skipping VarArg Function CLCursor (CLFunctionDecl) gal_arithmetic(int, int, int, ...)
└ @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:15
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/array.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/binary.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/blank.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/box.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/convolve.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/cosmology.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/data.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/dimension.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/eps.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/fits.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/git.h ...
┌ Warning: No Prototype for CLCursor (CLFunctionDecl) gal_git_describe() - assuming no arguments
└ @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:13
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/interpolate.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/jpeg.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/label.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/list.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/match.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/pdf.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/permutation.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/pointer.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/polygon.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/qsort.h ...
┌ Warning: not wrapping CLCursor (CLVarDecl) gal_qsort_index_single
└ @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:446
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/speclines.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/statistics.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/table.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/threads.h ...
┌ Warning: No Prototype for CLCursor (CLFunctionDecl) gal_threads_number() - assuming no arguments
└ @ Clang ~/.julia/packages/Clang/ypHaU/src/wrap_c.jl:13
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/tiff.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/tile.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/txt.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/type.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/units.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl
[ Info: wrapping header: /home/amcap1712/GNUAstro/gnuastro/wcs.h ...
[ Info: writing /home/amcap1712/GNUAstro/libgnuastro_api.jl

```

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [March 27, 2020, 2:32pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/10 "2020-03-27T14:32:24Z")

</div>

Is `/usr/include/limits.h` a valid path on your machine?

---

<div class="post-metadata">

**Author:** ![amCap1712](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amcap1712/32/13654_2.png) [@amCap1712](https://discourse.julialang.org/u/amCap1712)\
**Post date:** [March 27, 2020, 2:35pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/11 "2020-03-27T14:35:41Z")

</div>

> [@Gnimuc](#):
>
> `/usr/include/limits.h`

Yes I am able to view this file in terminal.

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [March 27, 2020, 2:37pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/12 "2020-03-27T14:37:36Z")

</div>

That’s strange. I’m going to test it on my machine.

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [March 27, 2020, 3:41pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/13 "2020-03-27T15:41:25Z")

</div>

```julia
using Clang
using Gnuastro_jll, WCS_jll, GSL_jll, CFITSIO_jll

const CFITSIO_INCLUDE = joinpath(dirname(CFITSIO_jll.libcfitsio_path), "..", "include") |> normpath
const GSL_INCLUDE = joinpath(dirname(GSL_jll.libgsl_path), "..", "include") |> normpath
const WCS_INCLUDE = joinpath(dirname(WCS_jll.libwcs_path), "..", "include") |> normpath
const GNUASTRO_INCLUDE = joinpath(dirname(Gnuastro_jll.libgnuastro_path), "..", "include") |> normpath
const GNUASTRO_HEADERS = [joinpath(GNUASTRO_INCLUDE, "gnuastro", header) for header in readdir(joinpath(GNUASTRO_INCLUDE, "gnuastro")) if endswith(header, ".h")]

wc = init(; headers = GNUASTRO_HEADERS,
            output_file = joinpath(@ __DIR__ , "libgnuastro_api.jl"),
            common_file = joinpath(@ __DIR__ , "libgnuastro_common.jl"),
            clang_includes = [GNUASTRO_INCLUDE, CFITSIO_INCLUDE, GSL_INCLUDE, WCS_INCLUDE, CLANG_INCLUDE],
            clang_args = ["-I", joinpath(GNUASTRO_INCLUDE, "gnuastro"),
                          map(x->"-I"*x, find_std_headers())...],
            header_wrapped = (root, current)->root == current,
            header_library = x->"libgnuastro",
            clang_diagnostics = true,
            )

run(wc)

```

This basically works, except the `error: unknown type name 'xxx'` error. After some investigation, it looks like Gnuastro did this intentionally, since Clang.jl currently has limitations for supporting multi-platform, you need to patch this yourself.

```julia
/* Define system specific types. For example `size_t' is 4 and 8 bytes on
   32 and 64 bit systems respectively. In both cases, the standard defines
   `size_t' to be unsigned. A similar case exists for `long', but it is
   signed. During `./configure' the sizeof `size_t' and `long' were found
   and are used to define an alias for these system specific types.

   Note: we are not using `else'. This is done because by any chance, if
   the length of these types is not what is expected (4 or 8), then the
   aliases are not defined and the compiler will crash. */
#if GAL_CONFIG_SIZEOF_SIZE_T == 4
#define GAL_TYPE_SIZE_T GAL_TYPE_UINT32
#elif GAL_CONFIG_SIZEOF_SIZE_T == 8
#define GAL_TYPE_SIZE_T GAL_TYPE_UINT64
#endif

#if GAL_CONFIG_SIZEOF_LONG == 4
#define GAL_TYPE_LONG GAL_TYPE_INT32
#define GAL_TYPE_ULONG GAL_TYPE_UINT32
#elif GAL_CONFIG_SIZEOF_LONG == 8
#define GAL_TYPE_LONG GAL_TYPE_INT64
#define GAL_TYPE_ULONG GAL_TYPE_UINT64
#endif

```

To get rid of all of the `error: unknown type name 'xxx'` errors, a dirty fix would be manually add `#include <stddef.h>` to `config.h`, `array.h`, `polygon.h`, `qsort.h`, `pointer.h`, `box.h` and add `#include <gnuastro/list.h> ` to `array.h`.

I posted the generated wrappers here: [LibGnuastro.jl · GitHub](https://gist.github.com/Gnimuc/c5122a7ba4c65652465858b07f0ea85a)

---

<div class="post-metadata">

**Author:** ![amCap1712](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amcap1712/32/13654_2.png) [@amCap1712](https://discourse.julialang.org/u/amCap1712)\
**Post date:** [March 27, 2020, 4:15pm UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/14 "2020-03-27T16:15:10Z")

</div>

Thanks for troublshooting. I am actually planning to create a fully functional Julia wrapper for GNUAstro. A direct interface to access GNUAstro and a Julia style interface to access it.

---

<div class="post-metadata">

**Author:** ![jdlara-berkeley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdlara-berkeley/32/4096_2.png) [@jdlara-berkeley](https://discourse.julialang.org/u/jdlara-berkeley)\
**Post date:** [January 5, 2021, 7:10am UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/15 "2021-01-05T07:10:13Z")

</div>

@Gnimuc I am having a similar issue with SuperLU\_MT. I get these error messages:

```julia
error: unknown type name 'int_t'

```

From the SuperLU\_MT FAQ I got this: “The parallel SuperLU\_DIST declares integers as “int\_t”, which can be defined as “int” or “long int” at compile time” But I am not sure if this is an issue with the Yggdrasil build or with the clang script.

This is my script (running in Mac Big Sur:

```julia
using Clang
using SuperLU_MT_jll

# `outpath` specifies, where the julian wrappers would be generated.
# If the generated .jl files are ok, they have to be copied to the "src" folder
# overwriting the old ones
const outpath = normpath(joinpath(dirname(@ __FILE__ ), "superlumt_wrapped_api"))
mkpath(outpath)

# Find all relevant SuperLU MT headers
const LIBCLANG_INCLUDE = joinpath(SuperLU_MT_jll.artifact_dir, "include") |> normpath
if !isdir(LIBCLANG_INCLUDE)
    error("SUPERLU MT C headers not found.")
end

const LIBCLANG_HEADERS = [joinpath(LIBCLANG_INCLUDE, header) for header in readdir(LIBCLANG_INCLUDE) if endswith(header, ".h")]

wc = Clang.init(
    headers = LIBCLANG_HEADERS,
    output_file = joinpath(outpath, "libsuperlumt_api.jl"),
    common_file = joinpath(outpath, "libsuperlumt_common.jl"),
    header_wrapped = (root, current) -> root == current,
    clang_includes = [CLANG_INCLUDE; LIBCLANG_INCLUDE],
    clang_args = String["-I" * header for header in Clang.find_std_headers()],
    header_library = x -> "libsuperlumt",
    clang_diagnostics = true,

)

run(wc)

```

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [January 5, 2021, 7:18am UTC](https://discourse.julialang.org/t/doubt-about-using-clang-jl/36599/16 "2021-01-05T07:18:04Z")

</div>

@jdlara-berkeley `_LONGINT` is defined [here](https://github.com/JuliaPackaging/Yggdrasil/blob/master/S/SuperLU_MT/build_tarballs.jl#L36) in the build script of SuperLU\_MT\_jll, so I think you need to pass this `-D_LONGINT` to `clang_args`.

`clang_args = String["-I" * header for header in Clang.find_std_headers(), "-D_LONGINT"]`

```julia
/* Define my integer type int_t */
#ifdef _LONGINT
typedef long long int int_t;
#define IFMT "%lld"
#else
typedef int int_t; /* default */
#define IFMT "%8d"
#endif

```

BTW, it looks like [the build script has more definitions](https://github.com/JuliaPackaging/Yggdrasil/blob/master/S/SuperLU_MT/build_tarballs.jl#L30), you might need to get all of these definitions passed correctly into `clang_args`.
