# Clang vs CBindingGen

**URL:** <https://discourse.julialang.org/t/clang-vs-cbindinggen/56693>\
**Category:** General Usage\
**Tags:** c, clang\
**Created:** [March 7, 2021, 7:06pm UTC](https://discourse.julialang.org/t/clang-vs-cbindinggen/56693 "2021-03-07T19:06:48Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![mhinsch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mhinsch/32/26676_2.png) [@mhinsch](https://discourse.julialang.org/u/mhinsch)\
**Post date:** [April 22, 2021, 7:45pm UTC](https://discourse.julialang.org/t/clang-vs-cbindinggen/56693/22 "2021-04-22T19:45:29Z")

</div>

Not really anything beyond a basic proof of concept. I basically used Gnumic’s example:

wrap.toml

```nohighlight
[general]
library_name = ":libraylib"
output_file_path = "./LibRaylib.jl"
module_name = "LibRaylib"
use_julia_native_enum_type = true

```

wrap.jl

```julia
using Clang.Generators

cd(@ __DIR__ )

const RAYLIB_H = ["/usr/local/include/raylib.h"]

options = load_options(joinpath(@ __DIR__ , "wrap.toml"))

args = String[]

ctx = create_context(RAYLIB_H, args, options)

build!(ctx)

```

Running `wrap.jl` produces `LibRayLib.jl` which is 99% fine, but needs a tiny bit of editing to account for issues with vararg functions and some macros (no idea if that has been fixed in the meantime). Then code like this works:

run\_rl.jl

```julia

include("LibRaylib.jl")

const RL = LibRaylib

const screen_width = 1600
const screen_height = 900

function run()
	RL.InitWindow(screen_width, screen_height, "run")

	camera = RL.Camera2D(RL.Vector2(500, 500), 
		RL.Vector2(screen_width/2, screen_height/2),
		0.0,
		1.0)

	x = floor(Int, rand() * 1000) + 200
	y = floor(Int, rand() * 700) + 100

	while RL.WindowShouldClose() == 0
		RL.BeginDrawing()
		
		RL.BeginMode2D(camera)
		RL.ClearBackground(RL.Color(0, 0, 0, 255))

		x += floor(Int, (rand()-0.49)*10)
		y += floor(Int, (rand()-0.49)*10)

		RL.DrawText("Dies ist ein Test!", 200, 200, 20, RL.Color(250, 0, 0, 255))
		RL.DrawCircle(x, y, 100, RL.Color(0, 255, 0, 150))

		RL.EndMode2D()

		RL.EndDrawing()
	end

	RL.CloseWindow()
end

run()

```

---

_[View the full topic](https://discourse.julialang.org/t/clang-vs-cbindinggen/56693)._
