---
name: "xprintf_comp"
section: "3"
platform: "macos"
package: "Libc"
version: "1752.120.2"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/xprintf_comp"
---

# xprintf\_comp(3)

extensible printf compilation

## NAME

**free\_printf\_comp**, **new\_printf\_comp** – extensible printf compilation

## SYNOPSIS

**#include \<printf.h\>**

*void*\

**free\_printf\_comp**(*printf\_comp\_t pc*);

*printf\_comp\_t*\

**new\_printf\_comp**(*printf\_domain\_t restrict domain*, *locale\_t restrict loc*, *const char \* restrict fmt*);

## DESCRIPTION

To ameliorate some of the slowness caused by the extra overhead in extensible printf (see [xprintf(5)](/xprintf/5.md)), a compile/execute mechanism has been created. The **new\_printf\_comp**() function compiles the given format string, along with a printf domain (see [xprintf\_domain(3)](/xprintf_domain/3.md)) and an extended locale (see [xlocale(3)](/xlocale/3.md)), and returns a *printf\_comp\_t* structure. The domain may not be NULL, but the locale can be NULL, which means to use the current locale, either the per-thread locale if it was set, or else the global locale. Because the *printf\_comp\_t* structure records the domain and locale, care should be taken if either of these are changed.

Once a *printf\_comp\_t* structure is created, it can be passed to one of the extensible printf execution variants, described in [xprintf\_exec(3)](/xprintf_exec/3.md), along with the necessary arguments. Creating the *printf\_comp\_t* structure needs to be done only once, but it can be passed to extensible printf execution variants any number of times.

When the *printf\_comp\_t* structure is no longer needed, it should be passed to **free\_printf\_comp**() to release internal memory.

## RETURN VALUES

The **new\_printf\_comp**() function returns the new structure, or NULL on error (usually NULL domain or out of memory condition).

## SEE ALSO

[xlocale(3)](/xlocale/3.md), [xprintf\_domain(3)](/xprintf_domain/3.md), [xprintf\_exec(3)](/xprintf_exec/3.md), [xprintf(5)](/xprintf/5.md)
