---
name: "elf_errno"
section: "3"
platform: "linux"
package: "libelf"
version: "0.197-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/elf_errno"
---

# elf\_errno(3)

retrieve the error code of the last failing libelf function call.

## NAME

elf\_errno - retrieve the error code of the last failing libelf function call.

## SYNOPSIS

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

**int elf\_errno(void);**

## DESCRIPTION

The **elf\_errno** function retrieves the error code of the last failing libelf library function. This error code indicates the type of error that occurred during the failing function call.  Each thread maintains its own separate error code.

## PARAMETERS

This function does not take any parameters.

## RETURN VALUE

The **elf\_errno** function returns an integer representing the most recent error code for the current thread. If no error has occurred, it returns 0. If an error occurred, the function returns a non-zero error code that corresponds to the specific error.  Error codes can be passed to **elf\_errmsg** in order to create a string describing the error.

## SEE ALSO

[**elf\_errmsg**(3)](/elf_errmsg/3.md)

## REPORTING BUGS

Report bugs to \<elfutils-devel@sourceware.org\> or https://sourceware.org/bugzilla/.
