how to display errors in a c program (windows 10)

0

This short c program has a divide by zero error.

#include <stdio.h>

    int main( int argc, const char* argv[] )
    {
        printf( "start\n" );
        int x = 0;
        printf("%d", 2/x);
        printf("end\n");    
    }

When I compile this with cl /Od /Zi /EHsc main.c and run it in the console the output is just 'start'. No error message or popup or any information about the error. If I run it in visual code debugger it traps the divide by zero fine. I also compiled it using tcc and it is exactly the same.

Is this normal behaviour? If so is there any way I can at least display that the divide by zero has happened (outside of a debugger). If not what on my Windows 10 machine could be preventing the errors being shown?

Edit: Just to make it clear:

I would have thought I would have seen something like "Unhandled exception at 0x00f5144b in main.exe: 0xC0000094: Integer division by zero." (or similar) Exactly the same thing happens when I deref a null pointer, the program just stops with no error message.

c
windows
compiler-errors
asked on Stack Overflow Mar 16, 2019 by Pajh • edited Mar 16, 2019 by Pajh

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0