Hello,

could you help me with the following error ?

1 // ConsoleClose.cpp
2
3 #include "StdAfx.h"
4
5 #include "ConsoleClose.h"
6
7 #include <signal.h>
8
9 static int g_BreakCounter = 0;
10 static const int kBreakAbortThreshold = 2;
11
12 namespace NConsoleClose {
13
14
15 #ifdef __cplusplus /* the __cplusplus macro */
16 extern "C" void HandlerRoutine(int); /* is automatically defined */
17 #else /* by the C++/MVS compiler */
18 void HandlerRoutine(int);
19 #endif
20
21 static void HandlerRoutine(int)
22 {
23 g_BreakCounter++;
24 if (g_BreakCounter < kBreakAbortThreshold)
25 return ;
26 exit(EXIT_FAILURE);
27 }
28
29 bool TestBreakSignal()
30 {
31 return (g_BreakCounter > 0);
32 }
33
34 void CheckCtrlBreak()
35 {
36 if (TestBreakSignal())
37 throw CCtrlBreakException();
38 }
39
40
41 CCtrlHandlerSetter::CCtrlHandlerSetter()
42
43 {
44 memo_sig_int = signal(SIGINT,HandlerRoutine); // CTRL-C
45 if (memo_sig_int == SIG_ERR)
46 throw "SetConsoleCtrlHandler fails (SIGINT)";
47 memo_sig_term = signal(SIGTERM,HandlerRoutine); // for kill -15 (before "kill -9")
48 if (memo_sig_term == SIG_ERR)
49 throw "SetConsoleCtrlHandler fails (SIGTERM)";
Compile error:

"../../UI/Console/ConsoleClose.cpp", line 21.13: CCN5400 (S) "NConsoleClose::HandlerRoutine(int)" has a conflicting declaration.
"../../UI/Console/ConsoleClose.cpp", line 16.18: CCN5424 (I) "HandlerRoutine" is declared on line 16 of "../../UI/Console/ConsoleClose.cpp".


If I remove "static" in line 21, I get :

"../../UI/Console/ConsoleClose.cpp", line 44.25: CCN5216 (S) An expression of type "extern "C" void (*)(int)" cannot be converted to type "void (*)(int)".
"../../UI/Console/ConsoleClose.cpp", line 45.8: CCN5207 (S) No common type found for operands with type "void (*)(int)" and "extern "C" void (*)(int)".
"../../UI/Console/ConsoleClose.cpp", line 47.26: CCN5216 (S) An expression of type "extern "C" void (*)(int)" cannot be converted to type "void (*)(int)".
Regards,
Nenad