From 2ec4257db100e0fac47e6675efa07d01f4545096 Mon Sep 17 00:00:00 2001 From: amarpMSFT Date: Mon, 25 Mar 2024 10:00:08 -0700 Subject: [PATCH] error printing fixes (#861) --- .../src/HelloWorkGraphs/D3D12HelloWorkGraphs.cpp | 4 ++-- .../src/WorkGraphsSandbox/D3D12WorkGraphsSandbox.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Samples/Desktop/D3D12HelloWorld/src/HelloWorkGraphs/D3D12HelloWorkGraphs.cpp b/Samples/Desktop/D3D12HelloWorld/src/HelloWorkGraphs/D3D12HelloWorkGraphs.cpp index c09a36cf8..030d0909e 100644 --- a/Samples/Desktop/D3D12HelloWorld/src/HelloWorkGraphs/D3D12HelloWorkGraphs.cpp +++ b/Samples/Desktop/D3D12HelloWorld/src/HelloWorkGraphs/D3D12HelloWorkGraphs.cpp @@ -39,8 +39,8 @@ bool g_useWarpDevice = false; // Look for "Start of interesting code" further below. //================================================================================================================================= -#define PRINT(text) cout << text << "\n" << flush; -#define VERIFY_SUCCEEDED(hr) {if(FAILED(hr)) {PRINT("Error at: " << __FILE__ << ", line: " << __LINE__ << hex << hr); throw E_FAIL;} } +#define PRINT(text) cout << (char*)text << "\n" << flush; +#define VERIFY_SUCCEEDED(hr) {HRESULT hrLocal = hr; if(FAILED(hrLocal)) {PRINT("Error at: " << __FILE__ << ", line: " << __LINE__ << ", HRESULT: 0x" << hex << hrLocal); throw E_FAIL;} } //================================================================================================================================= class D3DContext diff --git a/Samples/Desktop/D3D12HelloWorld/src/WorkGraphsSandbox/D3D12WorkGraphsSandbox.cpp b/Samples/Desktop/D3D12HelloWorld/src/WorkGraphsSandbox/D3D12WorkGraphsSandbox.cpp index 4acbe803e..2ef910e29 100644 --- a/Samples/Desktop/D3D12HelloWorld/src/WorkGraphsSandbox/D3D12WorkGraphsSandbox.cpp +++ b/Samples/Desktop/D3D12HelloWorld/src/WorkGraphsSandbox/D3D12WorkGraphsSandbox.cpp @@ -42,13 +42,13 @@ bool g_useWarpDevice = false; //================================================================================================================================= // Print with flush to get the text out in case there's delays in app -#define PRINT(text) cout << text << "\n" << flush; +#define PRINT(text) cout << (char*)text << "\n" << flush; #define PRINT_NO_NEWLINE(text) cout << text << flush; //================================================================================================================================= void Analyze(HRESULT hr) { - PRINT("HRESULT == "); + PRINT_NO_NEWLINE("HRESULT == "); switch (hr) { case DXGI_ERROR_DEVICE_HUNG: @@ -58,10 +58,10 @@ void Analyze(HRESULT hr) PRINT("DXGI_ERROR_DEVICE_REMOVED"); break; default: - PRINT(hex << hr); + PRINT("0x" << hex << hr); } } -#define VERIFY_SUCCEEDED(hr) {if(FAILED(hr)) {PRINT("Error at: " << __FILE__ << ", line: " << __LINE__ ); Analyze(hr); throw E_FAIL;} } +#define VERIFY_SUCCEEDED(hr) {HRESULT hrLocal = hr; if(FAILED(hrLocal)) {PRINT_NO_NEWLINE("Error at: " << __FILE__ << ", line: " << __LINE__ << ", "); Analyze(hrLocal); throw E_FAIL;} } //================================================================================================================================= class D3DContext