> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# newcclosure

> Returns a C closure for the provided function. If the function is already a C closure, the same function is returned. Passing a non-function raises a type error.

<div className="real-function-page">
  ```lua theme={null}
  newcclosure(func: function, debugName?: string): function
  ```

  ## 参数

  <ParamField path={"func"} type={"function"} required>
    Function to return directly when it is already a C closure, or wrap in a wrapped C closure otherwise.
  </ParamField>

  <ParamField path={"debugName"} type={"string"}>
    Optional debug name used for the created closure.
  </ParamField>

  ## 返回值

  <ResponseField name={"closure"} type={"function"}>
    The original function when it is already a C closure, or a new C closure that calls the provided function.
  </ResponseField>

  ## 示例

  Create a wrapped C closure for an L closure.

  ```lua theme={null}
  local function add(a, b)
      return a + b
  end

  local wrapped = newcclosure(add, "add")

  print(wrapped(2, 3))
  print(isnewcclosure(wrapped))
  ```
</div>
