|
Boost : |
Subject: Re: [boost] [assert] static_assert envy
From: Jim Bell (Jim_at_[hidden])
Date: 2011-01-17 16:38:46
On 1:59 PM, Mateusz Loskot wrote:
> On 17/01/11 17:24, Beman Dawes wrote:
>> On Mon, Jan 17, 2011 at 10:15 AM, Dean Michael Berris<
>> mikhailberis_at_[hidden]> wrote:
>>>
>>> Or would you rather use std::abort() just like the normal
>>> cassert implementation does?
>>>
>>
>> On Windows 7 (at least with VC++), abort() pops up one of those
>> "blah.exe
>> has stopped working" dialog boxes. I haven't been able to kill it, in
>> spite
>> of lots of google searches, and it drives me crazy.
>>
>> That said, std::abort() is probably right for many environments.
>
> This should do the trick:
>
> #include <cassert>
> #include <crtdbg.h> // Visual C++-specific
> int main()
> {
> #ifdef _MSC_VER
> // Redirect errors and assert() failures to stderr
> // instead of pop-up debug message window.
> // NOTE: Comment this 2 lines for debugging with
> // Visual C++ debugger to catch assertions inside.
> _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
> _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
> #endif //_MSC_VER
>
> assert(false && "test"); // no pop-up expected
> }
That's if you're in control of the code. Otherwise,
\HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\ForceQueue 1
I spent a few google iterations on that one, too. Other parameters have
appealing-sounding names
<http://msdn.microsoft.com/en-us/library/bb513638%28VS.85%29.aspx>, but
don't seem to affect the pop-up.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk