---
title: C / C++ Crash Reporting and Error Tracking
description: Set up Error Tracking for your C and C++ applications.
breadcrumbs: >-
  Docs > RUM & Session Replay > Application Monitoring > C / C++ Monitoring > C
  / C++ Crash Reporting and Error Tracking
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# C / C++ Crash Reporting and Error Tracking

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Overview{% #overview %}

Enable crash reporting for your C and C++ applications to surface, triage, and debug crashes in [Error Tracking](https://docs.datadoghq.com/real_user_monitoring/error_tracking.md). On Linux and macOS, the C++ SDK captures unhandled signals (such as `SIGSEGV` and `SIGABRT`). On Windows, it captures unhandled structured exceptions. In both cases, the SDK stores a crash report with the crashing thread's stack trace locally for upload on the next application launch.

Crash reports appear in [Error Tracking](https://docs.datadoghq.com/real_user_monitoring/error_tracking.md) and are deduplicated and grouped into issues to help you prioritize and resolve the most impactful crashes.

## Setup{% #setup %}

If you have not set up the RUM C++ SDK yet, follow the [in-app setup instructions](https://app.datadoghq.com/rum/application/create) or see the [RUM C++ setup documentation](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/cpp/setup.md).

To enable crash reporting, register the `CrashReporting` feature as early as possible after creating your SDK core, before calling `Start()`.

{% tab title="C++" %}

```cpp
#include "datadog.hpp"

datadog::CoreConfig config("<client_token>", "<service_name>", "<environment>");
auto core = datadog::Core::Create(config, datadog::TrackingConsent::Granted);

// Register crash reporting
auto crash_reporting = datadog::CrashReporting::Register(core);

// Register RUM
datadog::RumConfig rum_config("<rum_application_id>");
auto rum = datadog::Rum::Register(core, rum_config);

// Start the core
core->Start();
```

{% /tab %}

{% tab title="C (FFI)" %}

```c
#include "datadog.h"

dd_core_config_t config;
dd_core_config_init(&config, "<client_token>", "<service_name>", "<environment>");
dd_core_t* core = dd_core_create(&config, DD_TRACKING_CONSENT_GRANTED);

/* Register crash reporting */
dd_crash_reporting_t* crash_reporting = dd_crash_reporting_init(core, NULL);

/* Register RUM */
dd_rum_config_t rum_config;
dd_rum_config_init(&rum_config, "<rum_application_id>");
dd_rum_t* rum = dd_rum_init(core, &rum_config);

dd_core_start(core);
```

{% /tab %}

The SDK captures crashes automatically once registered.

### Crash reporting modes{% #crash-reporting-modes %}

The crash reporting mode is set at build time using the `DD_CRASH_MODE` CMake variable.

#### In-process (default){% #in-process-default %}

The default mode, `inprocess`, captures the stack trace of the crashing thread and stores it locally for upload on the next launch:

```cmake
set(DD_CRASH_MODE "inprocess" CACHE STRING "")
```

For accurate stack traces on Linux and macOS, compile your application with `-fno-omit-frame-pointer`. The in-process handler walks the call stack using frame pointers, and without this flag, stack traces may be incomplete or inaccurate.

#### Disabled (noop){% #disabled-noop %}

To disable crash reporting entirely without removing the API calls from your code, set `DD_CRASH_MODE` to `noop`:

```cmake
set(DD_CRASH_MODE "noop" CACHE STRING "")
```

### Symbolication{% #symbolication %}

To get human-readable function names and line numbers in your crash reports, upload your application's debug symbols to Datadog. See [RUM Debug Symbols](https://app.datadoghq.com/source-code/setup/rum) for setup instructions.

## Test your implementation{% #test-your-implementation %}

To verify that crash reporting is working:

1. Run your application with crash reporting enabled.
1. Trigger a crash. The simplest way is to use a direct system call:

{% tab title="POSIX" %}

```cpp
#include <signal.h>
raise(SIGSEGV);
```

{% /tab %}

{% tab title="Windows" %}

```c
#include <windows.h>
RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, NULL);
```

{% /tab %}
Relaunch the application. The crash report is uploaded during the next launch.After a few seconds, navigate to [Error Tracking](https://docs.datadoghq.com/real_user_monitoring/error_tracking.md) in Datadog to confirm the crash report appears.
## Further Reading{% #further-reading %}

- [Get started with Error Tracking](https://docs.datadoghq.com/real_user_monitoring/error_tracking.md)
- [Visualize Error Tracking data in the Explorer](https://docs.datadoghq.com/real_user_monitoring/error_tracking/explorer.md)
