# Generate a function via macro and pass to @cfunction. Possible?

**URL:** https://discourse.julialang.org/t/generate-a-function-via-macro-and-pass-to-cfunction-possible/123988
**Category:** General Usage
**Tags:** question, macros, c
**Created:** [December 19, 2024, 11:38am UTC](https://discourse.julialang.org/t/generate-a-function-via-macro-and-pass-to-cfunction-possible/123988 "2024-12-19T11:38:06Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![tqml](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tqml/32/22710_2.png) [@tqml](https://discourse.julialang.org/u/tqml)
#### Post date: [December 19, 2024, 1:24pm UTC](https://discourse.julialang.org/t/generate-a-function-via-macro-and-pass-to-cfunction-possible/123988/3 "2024-12-19T13:24:14Z")

</div>

Thanks for the reply and the explanation.

Is there any way to automatically define the wrapper function _before_ `@cfunction` is evaluated?

I want to have the implementation as user-friendly as possible and avoid that the user needs to first define a wrapper in global scope. It would be convenient if all of this could happen within one macro or function call.

---

_[View the full topic](https://discourse.julialang.org/t/generate-a-function-via-macro-and-pass-to-cfunction-possible/123988)._
