---
name: "canonicalize_file_name"
section: "3"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/canonicalize_file_name"
---

# canonicalize\_file\_name(3)

return the canonicalized absolute pathname

## NAME

canonicalize\_file\_name - return the canonicalized absolute pathname

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#define _GNU_SOURCE         /* See feature_test_macros(7) */
#include <stdlib.h>
```

**char \*canonicalize\_file\_name(const char \****path***);**

## DESCRIPTION

The **canonicalize\_file\_name**() function returns a null-terminated string containing the canonicalized absolute pathname corresponding to *path*. In the returned string, symbolic links are resolved, as are *.* and *..* pathname components. Consecutive slash (*/*) characters are replaced by a single slash.

The returned string is dynamically allocated by **canonicalize\_file\_name**() and the caller should deallocate it with [**free**(3)](/free/3.md) when it is no longer required.

The call *canonicalize\_file\_name(path)* is equivalent to the call:

```
realpath(path, NULL);
```

## RETURN VALUE

On success, **canonicalize\_file\_name**() returns a null-terminated string. On error (e.g., a pathname component is unreadable or does not exist), **canonicalize\_file\_name**() returns NULL and sets *errno* to indicate the error.

## ERRORS

See [**realpath**(3)](/realpath/3.md).

## ATTRIBUTES

For an explanation of the terms used in this section, see [**attributes**(7)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **canonicalize\_file\_name**() | Thread safety | MT-Safe |

## STANDARDS

GNU.

## SEE ALSO

[**readlink**(2)](/readlink/2.md), [**realpath**(3)](/realpath/3.md)
