---
name: "TPMLIB_ChooseTPMVersion"
section: "3"
platform: "linux"
package: "libtpms"
version: "0.10.2-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/TPMLIB_ChooseTPMVersion"
---

# TPMLIB\_ChooseTPMVersion(3)

Choose the version of the TPM

## NAME

TPMLIB\_ChooseTPMVersion    - Choose the version of the TPM

## SYNOPSIS

**#include \<libtpms/tpm\_types.h**\>

**#include \<libtpms/tpm\_library.h**\>

**TPM\_RESULT TPMLIB\_ChooseTPMVersion(TPMLIB\_TPMVersion** *ver***);**

```
 typedef enum TPMLIB_TPMVersion {
    TPMLIB_TPM_VERSION_1_2,
    TPMLIB_TPM_VERSION_2,
 } TPMLIB_TPMVersion;
```

## DESCRIPTION

The **TPMLIB\_ChooseTPMVersion()** function is used to choose the version of the TPM, either a TPM 1.2 or TPM 2.

This function must be called before **TPMLIB\_MainInit()** is called and will otherwise return an error. This function may be called again once **TPMLIB\_Terminate()** has been called.

If this function is not called, the last chosen TPM version will be started with **TPMLIB\_MainInit()**. If this function is not called, a TPM  1.2 will be used.

## ERRORS

- **TPM\_SUCCESS**

  The version of the TPM was chosen successfully.

- **TPM\_FAIL**

  The choice of the TPM was wrong, or **TPMLIB\_MainInit()** has already been called.

For a complete list of TPM error codes please consult the include file **libtpms/tpm\_error.h**

## SEE ALSO

[**TPMLIB\_MainInit**(3)](/TPMLIB_MainInit/3.md), [**TPMLIB\_Terminate**(3)](/TPMLIB_Terminate/3.md)
