---
name: "PkgRequire"
section: "3"
platform: "macos"
package: "tcl"
version: "152"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/PkgRequire"
---

# PkgRequire(3)

package version control

## NAME

Tcl\_PkgRequire, Tcl\_PkgRequireEx, Tcl\_PkgRequireProc, Tcl\_PkgPresent, Tcl\_PkgPresentEx, Tcl\_PkgProvide, Tcl\_PkgProvideEx - package version control

## SYNOPSIS

```
#include <tcl.h>

const char *
Tcl_PkgRequire(interp, name, version, exact)

const char *
Tcl_PkgRequireEx(interp, name, version, exact, clientDataPtr)

int
Tcl_PkgRequireProc(interp, name, objc, objv, clientDataPtr)

const char *
Tcl_PkgPresent(interp, name, version, exact)

const char *
Tcl_PkgPresentEx(interp, name, version, exact, clientDataPtr)

int
Tcl_PkgProvide(interp, name, version)

int
Tcl_PkgProvideEx(interp, name, version, clientData)
```

## ARGUMENTS

Interpreter where package is needed or available. Name of package. A version string consisting of one or more decimal numbers separated by dots. Non-zero means that only the particular version specified by *version* is acceptable. Zero means that newer versions than *version* are also acceptable as long as they have the same major version number as *version*. Arbitrary value to be associated with the package. Pointer to place to store the value associated with the matching package. It is only changed if the pointer is not NULL and the function completed successfully. Number of requirements. Array of requirements.

## DESCRIPTION

These procedures provide C-level interfaces to Tcl's package and version management facilities.

**Tcl\_PkgRequire** is equivalent to the **package require** command, **Tcl\_PkgPresent** is equivalent to the **package present** command, and **Tcl\_PkgProvide** is equivalent to the **package provide** command.

See the documentation for the Tcl commands for details on what these procedures do.

If **Tcl\_PkgPresent** or **Tcl\_PkgRequire** complete successfully they return a pointer to the version string for the version of the package that is provided in the interpreter (which may be different than  *version*); if an error occurs they return NULL and leave an error  message in the interpreter's result.

**Tcl\_PkgProvide** returns **TCL\_OK** if it completes successfully; if an error occurs it returns **TCL\_ERROR** and leaves an error message in the interpreter's result.

**Tcl\_PkgProvideEx**, **Tcl\_PkgPresentEx** and **Tcl\_PkgRequireEx** allow the setting and retrieving of the client data associated with the package. In all other respects they are equivalent to the matching functions.

**Tcl\_PkgRequireProc** is the form of **package require** handling multiple requirements. The other forms are present for backward compatibility and translate their invocations to this form.

## KEYWORDS

package, present, provide, require, version
