---
name: "SetErrno"
section: "3tcl"
platform: "linux"
package: "tcl8.3-doc"
version: "8.3.5-13"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/SetErrno/3tcl"
---

# SetErrno(3tcl)

manipulate errno to store and retrieve error codes

```

```

## NAME

Tcl\_SetErrno, Tcl\_GetErrno, Tcl\_ErrnoId, Tcl\_ErrnoMsg - manipulate errno to store and retrieve error codes

## SYNOPSIS

```
#include <tcl.h>

void
Tcl_SetErrno(errorCode)

int
Tcl_GetErrno()

char *
Tcl_ErrnoId()

char *
Tcl_ErrnoMsg()

```

## ARGUMENTS

- int *errorCode* (in)

  A POSIX error code such as **ENOENT**.

  ```

  ```

## DESCRIPTION

**Tcl\_SetErrno** and **Tcl\_GetErrno** provide portable access to the **errno** variable, which is used to record a POSIX error code after system calls and other operations such as **Tcl\_Gets**. These procedures are necessary because global variable accesses cannot be made across module boundaries on some platforms.

**Tcl\_SetErrno** sets the **errno** variable to the value of the *errorCode* argument C procedures that wish to return error information to their callers via **errno** should call **Tcl\_SetErrno** rather than setting **errno** directly.

**Tcl\_GetErrno** returns the current value of **errno**. Procedures wishing to access **errno** should call this procedure instead of accessing **errno** directly.

**Tcl\_ErrnoId** and **Tcl\_ErrnoMsg** return a string representation of the current **errno** value.  **Tcl\_ErrnoId** returns a machine-readable textual identifier such as "EACCES". **Tcl\_ErrnoMsg** returns a human-readable string such as "permission denied".  The strings returned by these functions are statically allocated and the caller must not free or modify them.

## KEYWORDS

errno, error code, global variables
