---
name: "pmem2_errormsg"
section: "3"
platform: "linux"
package: "libpmem2-dev"
version: "1.13.1-1.1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/pmem2_errormsg"
---

# pmem2\_errormsg(3)

returns last error message

## NAME

**pmem2\_errormsg**() - returns last error message

## SYNOPSIS

-

  ```
  #include <libpmem2.h>
  const char *pmem2_errormsg(void);
  ```

## DESCRIPTION

If an error is detected during the call to a [**libpmem2**(7)](/libpmem2/7.md) function, the application may retrieve an error message describing the reason of the failure from **pmem2\_errormsg**(). The error message buffer is thread-local; errors encountered in one thread do not affect its value in other threads. The buffer is never cleared by any library function; its content is significant only when the return value of the immediately preceding call to a [**libpmem2**(7)](/libpmem2/7.md) function indicated an error. The application must not modify or free the error message string. Subsequent calls to other library functions may modify the previous message.

## RETURN VALUE

The **pmem2\_errormsg**() function returns a pointer to a static buffer containing the last error message logged for the current thread. If *errno* was set, the error message may include a description of the corresponding error code as returned by [**strerror**(3)](/strerror/3.md).

## SEE ALSO

[**strerror**(3)](/strerror/3.md), [**libpmem2**(7)](/libpmem2/7.md) and **\<https://pmem.io\>**
