---
name: "hal_init"
section: "3hal"
platform: "linux"
package: "linuxcnc-uspace-dev"
version: "1:2.9.4-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/hal_init"
---

# hal\_init(3hal)

Sets up HAL and RTAPI

## NAME

hal\_init - Sets up HAL and RTAPI

## SYNTAX

 int hal\_init(const char \**modname*)

## ARGUMENTS

- *modname*

  The name of this HAL module

## DESCRIPTION

**hal\_init** sets up HAL and RTAPI.  It must be called by any module that intends to use the API, before any other RTAPI calls.

*modname* must point to a string that identifies the module. The string may be no longer than **HAL\_NAME\_LEN** characters.

## REALTIME CONSIDERATIONS

Call only from within non-realtime or init/cleanup code, not from realtime tasks.

## RETURN VALUE

On success, returns a positive integer module ID, which is used for subsequent calls to HAL and rtapi APIs. On failure, returns a HAL error code.
