سؤال

It seems that SetErrorMode(SEM_NOGPFAULTERRORBOX), suppresses division by zero.

Code to reproduce:

SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX); // Comment out this line and an error dialog will appear.
int a = 5;
printf("%d", 1/(a-5));

Why is that? From the name I assume it should suppress only General Protection Fault, which has nothing to do with division by zero.

هل كانت مفيدة؟

المحلول

From the MSDN reference page:

The system does not display the Windows Error Reporting dialog.

This means that when you set the flag, it suppresses all error dialogs.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top