How can I catch a runtime error in ansi C90

I am using the Function ConnectToTCPServer library . This feature is disabled when the host is unavailable. In this case, the application crashes with the following error: "Non-FATAL RUN-TIME error:" MyClient.c ", line 93, column 15, flow identifier 0x000017F0: library function error (returned value == -11 [0xfffffff5]) "Timeout error"

Error code 11 is a timeout error, so this can happen quite often in my application - however the application crashes - I would like to catch this error, not the application crashing.

How can I catch this runtime error in Ansi C90?

EDIT: The following is the code for the current usage:

ConnectToTCPServer(&srvHandle, srvPort, srvName, HPMClientCb, answer, timeout);

with

int HPMClientCb(UINT handle, int xType, int errCode, void *transData){
    printf("This was never printed\n");
    return errCode;
}

callback . , ConnectToTCPServer . , , .

EDIT 2: Callback , Returnvalue ConnectToTCPServer . , , ConnectToTCPServer . C90. ?

EDIT 3: , , , - , - , .

+3
6

NI :
" - , LabWindows/CVI ".

, , , , .

, , , :
// If debugging is enabled, this function directs LabWindows/CVI not
// to display a run-time error dialog box when a National Instruments
// library function reports an error.
DisableBreakOnLibraryErrors();

, .

+3

, "" ( "" ) C. , , . , , abort(). Unix, SIGABRT, , exit() ed. , exit().

, strace, , .

, .

+2

, , clientCallbackFunction . , , .

+1

, .

ConnectToTCPServer(). int; 0 , - .

: :

ConnectToTCPServer(&srvHandle, srvPort, srvName, HPMClientCb, answer, timeout);

, , , , ConnectToTCPServer() .

int err_code;
...
err_code = ConnectToTCPServer(&srvHandle, srvPort, srvName, HPMClientCb, answer, timeout);

err_code.

ConnectToTCPServer() , , TCP. , .

  • ConnectToTCPServer() .
  • ConnectToTCPServer().
  • , - .

?

+1

. , , , - ( - ). (, , , ), .

0

, ConnectToTCPServer . , , .

, , , FATAL, . , , ​​.

I am not familiar with CVI, but there may be an option (compile- / runtime-) to cancel even with non-fatal errors (for debugging purposes). If you can reproduce this in a minimal example, you should report it to NI .

0
source

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


All Articles