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

# gelf\_getclass(3)

return the ELF class (32-bit or 64-bit) for an object

## NAME

gelf\_getclass - return the ELF class (32-bit or 64-bit) for an object

## SYNOPSIS

```
#include <gelf.h>
int gelf_getclass(Elf *elf);
```

## DESCRIPTION

**gelf\_getclass**() returns the class of the ELF object referenced by *elf*. The class of a valid ELF file will be one of:

- **ELFCLASS32**

  The object is a 32-bit ELF class.

- **ELFCLASS64**

  The object is a 64-bit ELF class.

If *elf* does not denote a valid ELF object, or the class cannot be determined, **ELFCLASSNONE** is returned.

## RETURN VALUE

Returns **ELFCLASS32** or **ELFCLASS64** on success. If *elf* is NULL or does not refer to a valid ELF binary with kind **ELF\_K\_ELF**, then **ELFCLASSNONE** is returned.

## SEE ALSO

[**elf\_kind**(3)](/elf_kind/3.md), [**libelf**(3)](/libelf/3.md), [**elf**(5)](/elf/5.md)

## ATTRIBUTES

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **gelf\_getclass**() | Thread safety | MT-unsafe race |

## REPORTING BUGS

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