|
Boost : |
Subject: Re: [boost] [assert] static_assert envy
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2011-01-17 12:58:33
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
}
Best regards,
-- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org Member of ACCU, http://accu.org
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk