Skip to content

Exit Codes Windows -

If your main() throws an uncaught C++ exception, the CRT catches it, calls terminate() , and then ExitProcess(3) . The code 3 means nothing about your logic—it simply signals "CRT abnormal termination."

| Category | Range (Hex) | Example | Meaning | |----------|-------------|---------|---------| | | 0x00000000–0x0000FFFF | 1 , 2 | Custom error (e.g., invalid input) | | Win32 Error Codes | 0x00000000–0x0000FFFF (overlap!) | ERROR_FILE_NOT_FOUND (2) | System API failure | | NTSTATUS Codes | 0xC0000000–0xFFFFFFFF | 0xC0000005 | Access violation (structured exception) | | HRESULT | 0x80070000–0x8007FFFF | 0x80070002 | COM error, wraps Win32 error 2 | exit codes windows

This overlap is a trap: an exit code of 2 could mean "invalid parameter" (application-defined), or it could mean ERROR_FILE_NOT_FOUND from a failed CreateFile . Without the program's documentation, you cannot disambiguate. Three common scenarios produce exit codes that are technically correct but semantically useless: If your main() throws an uncaught C++ exception,

x