Windows: preventing assert () attempts when opening a debug popup

How can I prevent a debug pop-up from appearing when the approval fails on a Windows machine? The application I'm writing is console based, and I use assert () to test certain things when it runs in test mode. I am using MinGW + GCC 4.

Edit: this is a test program.

#include <stdlib.h>
#include <assert.h>

int main(void) {
    _set_error_mode(_OUT_TO_STDERR);
    assert(0 == 1);
    return EXIT_SUCCESS;
}

Flags: gcc -mwindows -pedantic -Wall -Wextra -c -g -Werror -MMD -MP -MF ...

I tried without -mwindows. I still get a debug popup, no matter what. This is on a Vista x86 machine.

+3
source share
2 answers

. - assert (. mingw assert.h). ( ):

_set_error_mode (_OUT_TO_STDERR);

: , :

#include <stdlib.h>
#include <assert.h>

int main (void)
{
  _set_error_mode (_OUT_TO_STDERR);
  assert (0 == 1);
  return 0;
}

gcc -mwindows, . _set_error_mode . , , .

+3

, :

SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
+2

Source: https://habr.com/ru/post/1730244/


All Articles