I have a question regarding the definition to the ThrowIfFailed() function used in DirectX12 code applications.

Joseph Klasen 146 Reputation points
2022-11-29T18:23:59.837+00:00

In the course of coding DirectX12 applications, I find frequent references to the ThrowIfFailed() function, but I have not not been able to get the definition that is given in the Helpers.h header file to compile:

define WIN32_LEAN_AND_MEAN

include <Windows.h> // For HRESULT

// From DXSampleHelper.h
// Source: https://github.com/Microsoft/DirectX-Graphics-Samples
inline void ThrowIfFailed(HRESULT hr)
{
if (FAILED(hr))
{
throw std::exception();
}
}

Including this definition in my DX12 code results in my compiler flagging the exception() function as not being a part of the STD namespace.

So, I have three questions regarding this - Is the principle reason for the ThrowIfFailed() function to provide a breakpoint in DX12 code (as I have read), and secondly, where can I find a reference to a definition that does compile?

My third question involves the use of TAGS in this forum - I have not yet figured out the labeling hierarchy used in tags that are available for questions - for instance, I discovered there is no DirectX12 tag for this post, so I am using the closest thing I find. Where do I find more about choosing appropriate tags?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,512 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 83,106 Reputation points
    2022-11-29T18:59:39.95+00:00

    The code sample from D3D12HelloWorld compiles normally for me : DXSampleHelper.h
    with std::exception() from VS 2022 install directory (Microsoft Visual Studio_2020 on my PC...)
    E:\Program Files\Microsoft Visual Studio_2020\VC\Tools\MSVC\14.34.31933\include\vcruntime_exception.h

    0 comments No comments

0 additional answers

Sort by: Most helpful