Similar piece of code to that I recently posted as:Resolving a linkI have another piece of code which cannot be as easily extracted out into a method:#define THROW_LAST_WINDOWS_ERROR()\    WindowsApi::Exception::Throw(::GetLastError(), __FILE__,  __LINE__)#define THROW_MANUAL_WINDOWS_ERROR(x)\    WindowsApi::Exception::Throw(x, __FILE__,  __LINE__)Process CreateNormalProcess(    ProcessSnapshot *parent,    const UNICODE_STRING& name,     const unsigned __int32 pid,    const std::vector<ToolHelpThread>& threads    ){    std::wstring nameStr(name.Buffer, name.Length/sizeof(wchar_t));    std::wstring commandLine;    std::wstring mainModulePath;    std::wstring error;    std::vector<Module> modules;    try    {        using WindowsApi::Dll::NtDll;        using WindowsApi::AutoArray;        HANDLE hProc = OpenProcess(            PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE,            pid);        if (hProc == 0)        {            THROW_LAST_WINDOWS_ERROR();        }        //Populate the process environment block        NtDll ntDll;        PEB peb;        AutoArray procInfoBuf = ntDll.NtQueryInformationProcess(            ProcessBasicInformation,            hProc,            sizeof(PROCESS_BASIC_INFORMATION)            );        BOOL rpmError = ReadProcessMemory(            hProc,            procInfoBuf.GetAs<PROCESS_BASIC_INFORMATION>()->PebBaseAddress,            &peb,            sizeof(peb),            0);        if (rpmError == 0)        {            THROW_LAST_WINDOWS_ERROR();        }        RTL_USER_PROCESS_PARAMETERS procParameters;        rpmError = ReadProcessMemory(hProc,            peb.ProcessParameters,            &procParameters,            sizeof(procParameters),            0);        if (rpmError == 0)        {            THROW_LAST_WINDOWS_ERROR();        }        commandLine.assign(ReadRemoteUnicodeString(hProc,            procParameters.CommandLine));        mainModulePath.assign(ReadRemoteUnicodeString(hProc,            procParameters.ImagePathName));        PEB_LDR_DATA ldrData;        rpmError = ReadProcessMemory(hProc,            peb.Ldr,            static_cast<void *>(&ldrData),            sizeof(PEB_LDR_DATA),            0);        if (rpmError == 0)        {            THROW_LAST_WINDOWS_ERROR();        }        void * endPointer = static_cast<void *>            (reinterpret_cast<char *>(peb.Ldr) + (reinterpret_cast<char *>(&ldrData.InLoadOrderModuleList) - reinterpret_cast<char *>(&ldrData)));        void * currentListEntry = ldrData.InLoadOrderModuleList.Flink;        while (currentListEntry != endPointer)        {            LDR_MODULE loaderModule;            rpmError = ReadProcessMemory(                hProc,                currentListEntry,                &loaderModule,                sizeof(loaderModule),                0);            if (rpmError == 0)            {                THROW_LAST_WINDOWS_ERROR();            }            std::wstring moduleName = ReadRemoteUnicodeString(hProc, loaderModule.FullDllName);            modules.push_back(Module(                moduleName,                loaderModule.BaseAddress,                loaderModule.SizeOfImage                ));            currentListEntry = loaderModule.InLoadOrderModuleList.Flink;        }        CloseHandle(hProc);    }    catch (const ErrorAccessDeniedException&)    {        error.assign(LERROR: Could not access additional information because access             Lwas denied while attempting to open the process. Are you admin? Do you             Lhave SeDebugPrivilege?);    }    catch (const ErrorInvalidParameterException&)    {        error.assign(LERROR: The process terminated before additional information             Lcould be extracted);    }    catch (const ErrorPartialCopyException&)    {        error.assign(LERROR: Couldn't copy a data structure from this process. Either             Lthe process terminated before information extraction, or you are running             Lthe 32 bit version of pevFind on a 64 bit machine.);    }    if (!error.empty())    {        if (nameStr.empty())        {            nameStr = error;        }        if (commandLine.empty())        {            commandLine = error;        }        if (mainModulePath.empty())        {            mainModulePath = error;        }    }    return Process(        parent,        pid,        nameStr,         commandLine,        mainModulePath,        threads,        modules);}The problem here is twofold:I can't extract out the duplicated if blocks into a method, because it's necessary that they embed the __FILE__ and __LINE__.I can't put the conditional check into a macro, because the controlled method spans multiple lines:MYMACRO(    Function(    Call,    Spanning,    Multiple,    Lines));doesn't seem to expand correctly.
Resolving a link - follow-up
c++;macros
The MYMACRO call should be fine.#define D3DCALL(a) { auto __ = a; if (FAILED(__)) DXTrace(__FILE__, __LINE__, __, WIDEN(#a), TRUE); }D3DCALL(D3DXCreateSphere(    D3DDev.get(),    radius,    slices,    slices,    &retval->Mesh._Myptr,    &retval->Adjacency._Myptr));I use this in my own source code all the time. The main way you get problems is if you try to conditionally compile within the macro call.