---
source_url: https://www.pubnub.com/docs/sdks/c-core/troubleshoot
title: Troubleshooting C-Core SDK (legacy)
updated_at: 2026-09-30T07:20:08.000Z
sdk_name: PubNub C/C++ Core SDK
sdk_version: 7.3.5
---

# Troubleshooting C-Core SDK (legacy)

PubNub C/C++ Core SDK, use the latest version: 7.3.5

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

:::note New SDK available
C-Core (legacy) is still supported. If you are starting a new project, use the new [C SDK](https://www.pubnub.com/docs/sdks/c.md).
:::

This page explains how to use the assertion subsystem for troubleshooting in the PubNub C-Core (legacy) Software Development Kit (SDK).

## Using the PUBNUB_ASSERT subsystem

The `PUBNUB_ASSERT` subsystem helps you catch and fix bugs when working with the C-Core (legacy) SDK.

When your code encounters an unexpected condition, assertions immediately flag the problem and show exactly which file and line caused the error.

You can control how strict these checks are - use more thorough validation during development to catch more issues, or fewer checks in production for better performance.

Custom assertion handlers let you decide what happens when failures occur, from simple logging to triggering debugger breakpoints.

C-Core (legacy) has its own `ASSERT` module/subsystem. Its interface is in the header `pubnub_assert.h`. It is used in C-Core (legacy) modules themselves, but you can also use it in your code if you wish. It provides several levels of `ASSERTs`:

| Level | Preprocessor Symbol | Description |
| --- | --- | --- |
| highest | `PUBNUB_ASSERT_LEVEL_EX` | All checks enabled (compiled). |
| regular | `PUBNUB_ASSERT_LEVEL` | Only the long lasting checks are disabled, other are compiled. |
| lowest | `PUBNUB_ASSERT_LEVEL_OPT` | Only the checks with negligible execution length are enabled. |
| none | `PUBNUB_ASSERT_LEVEL_NONE` | All checks disabled. |

The default level is `highest`, and that is the level used in our sample `Makefiles`.

If you want to troubleshoot performance by disabling checks, define `PUBNUB_ASSERT_LEVEL_NONE`.

Also, you can control what happens when an assertion fails. To do that, you set a `callback` function to be called, by using `pubnub_assert_set_handler()`, which should be called as early as possible in the execution of your program.

There are a few ready-made handlers which you can use and the default is `pubnub_assert_handler_abort`, which provides a similar operation as the C standard `assert()` macro - prints a report of the place and expression of the assertion and then aborts.

If you wish to provide your own handler, you need to define a function that conforms to the following typedef:

```c
typedef void (*pubnub_assert_handler_t)(char const *s, char const *file, long line);
```

For example:

```c
void dbg_break_assert_handler(char const *s, char const *file, long line)
{
    printf("Will hit breakpoint for '%s' in %s line %d\n", s, file, line);
    BREAK_IN_DEBUGGER; /* assuming you have such a macro */
}
```

### Change the assertion level

To change the assertion level:

1. Edit the Makefile you wish to use to compile your client, for example [posix.mk](https://github.com/pubnub/c-core/blob/master/openssl/posix.mk).
2. In the file, find the list of `CFLAGS` or `DEFINES`:

   ```make
   CFLAGS = -g -D PUBNUB_THREADSAFE -D PUBNUB_LOG_LEVEL=PUBNUB_LOG_LEVEL_WARNING -Wall -D PUBNUB_ONLY_PUBSUB_API=$(ONLY_PUBSUB_API)
   (...)
   ```

3. Add the `-D <level>` where level is one of the preprocessor symbols found in this [table](#using-the-pubnub_assert-subsystem), for example:

   ```make
   CFLAGS = -g (...) -D PUBNUB_ASSERT_LEVEL_OPT
   ```

Last updated at: 2026-09-30T07:20:08.000Z
