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

# rtapi\_print(3rtapi)

print diagnostic messages

## NAME

rtapi\_print, rtapi\_print\_msg - print diagnostic messages

## SYNTAX

void rtapi\_print(const char \**fmt*, *...*)

void rtapi\_print\_msg(int level, const char \**fmt*, *...*)

typedef void(\***rtapi\_msg\_handler\_t**)(msg\_level\_t *level*, const char \**msg*);

void **rtapi\_set\_msg\_handler**(rtapi\_msg\_handler\_t *handler*);

rtapi\_msg\_handler\_t **rtapi\_get\_msg\_handler**(void);

## ARGUMENTS

- *level*

  A message level: One of **RTAPI\_MSG\_ERR**, **RTAPI\_MSG\_WARN**, **RTAPI\_MSG\_INFO**, or **RTAPI\_MSG\_DBG**.

- *handler*

  A function to call from **rtapi\_print** or **rtapi\_print\_msg** to actually output the message.

- *fmt, ...*

  Other arguments are as for *rtapi\_vsnprintf(3rtapi)*.

## DESCRIPTION

**rtapi\_print** and **rtapi\_print\_msg** work like the standard C printf functions, except that a reduced set of formatting operations are supported.  Notably, formatting long-long values is not supported, and formatting floating-point values has different behavior than standard printf.

Depending on the RTOS, the default may be to print the message to stdout, stderr, a kernel log, etc.   In RTAPI code, the action may be changed by a call to **rtapi\_set\_msg\_handler**.  A **NULL** argument to **rtapi\_set\_msg\_handler** restores the default handler. **rtapi\_msg\_get\_handler** returns the current handler.  When the message came from **rtapi\_print**, *level* is RTAPI\_MSG\_ALL.

**rtapi\_print\_msg** works like rtapi\_print but only prints if *level* is less than or equal to the current message level.

## REALTIME CONSIDERATIONS

**rtapi\_print** and **rtapi\_print\_msg** May be called from non-realtime, init/cleanup, and realtime code.  **rtapi\_get\_msg\_handler** and **rtapi\_set\_msg\_handler** may be called from realtime init/cleanup code.  A message handler passed to **rtapi\_set\_msg\_handler** may only call functions that can be called from realtime code.

## RETURN VALUE

None.

## SEE ALSO

**[rtapi\_set\_msg\_level(3rtapi)](/rtapi_set_msg_level/3rtapi.md)**, **[rtapi\_get\_msg\_level(3rtapi)](/rtapi_get_msg_level/3rtapi.md)**, **rtapi\_vsnprintf(3rtapi)**
