Document number:







René Ferdinand Rivera Morell,


ISO/IEC JTC1/SC22/WG21 14882: Programming Language — C++

1. Abstract

This paper proposes a new function, std::is_debugger_present, that checks if a program is being debugged to aid in software development.

2. Revision History

2.1. Revision 0 (January 2022)

Initial text.

3. Motivation

There are many scenarios where doing something special when your program is running in a debugger is important. That can take the form of:

  • allowing printing out extra output to help diagnose problems,

  • executing extra test code,

  • displaying an extra user interface to help in debugging,

  • and more.

This is something that appears in many development environments but is hard to do as it requires intimate platform knowledge. Making this facility available would improve the program debugging experience of the average user. And spare them the burden of acquiring arcane platform knowledge to implement, over and over, this functionality.

4. Design Decisions

The goal of the std::is_debugger_present function is to inform when a program is executing under the control of a debugger monitoring program. The interface is minimally simple to avoid having to reduce the user from having to know the intricacies of debugger operation. This is a feature that requires arcane platform knowledge for most platforms. But it is knowledge that is readily available to the platform tooling implementors.

The std::is_debugger_present function is intended to go into a <debugging> header.

4.1. Impact On the Standard

This proposal adds a utility header and a single function the implementation of which is readily available to the platform tooling implementors.

5. Implementation Experience

In addition to the prototype implementation [1] there are the following, full or partial, equivalent implementations:

  • Windows provides a IsDebuggerPresent function in the OS with the same functionality. [2]

  • Unreal Engine 4 implements the same as a IsDebuggerPresent function for a variety of platforms.

  • Catch2 implements the same as a isDebuggerActive function. [3]

6. Wording

Wording is relative to N4868. [4]

6.1. Library

Add a new entry to General utilities library summary [utilities.summary] table.




Add section to General utilities library [utilities].

6.1.1. Debugging [debugging] In general [debugging.general]

Subclause [debugging] describes the debugging library that provides functionality to introspect and interact with a debugger that is executing and monitoring the running program. Header <debugging> synopsis [debugging.syn]
namespace std {
	// [debugging.utility], utility
	bool is_debugger_present() noexcept;
} Utility [debugging.utility]

bool is_debugger_present() noexcept;

Returns: If the program is currently running under a debugger it returns true, otherwise false.

Remarks: If not supported by the implementation it returns false.

7. Acknowledgements

1. Debugging prototype implementation (
2. Win32 IsDebuggerPresent (
3. Catch2 isDebuggerActive (
4. N4868 Working Draft, Standard for Programming Language C++ 2020-10-18 (