Hi there,
A quick(ish) question about macros. I managed to get some of the code I've been learning lately to work for myself. I'm just not sure why it works. It contains a syntax I've not used before:
When run like so:Code:#ifndef getFunctionName #define getFunctionName(x) \ { \ HRESULT hr = (x); \ if (hr == E_FAIL)MessageBoxW(NULL, L#x, L"Function Failed", 0); \ } #endif
It works fine. I'm just unsure as to how exactly the code manages to retrieve an entire function name from a returned HRESULT using the L#x part, and I also don't know why the macro has the single backslashes \ in it for each line. The compiler wouldn't allow compilation without them though.Code:getFunctionName(ReturnFail()); // definition HRESULT ReturnFail() { return E_FAIL; }
Any ideas? Thanks