# HG changeset patch # User greg # Date 1253107154 -7200 # Node ID 513f5ec8b628be2c5b279f745ab8191a1e4fc93a # Parent aba1bf1defc6fb324038298baf235ade6590b811 add extern C to maintain compatibility with C++ fix warnings with msvc compiler diff -r aba1bf1defc6 -r 513f5ec8b628 drivers/timers_win32/timers_win32.c --- a/drivers/timers_win32/timers_win32.c Wed Sep 16 15:18:23 2009 +0200 +++ b/drivers/timers_win32/timers_win32.c Wed Sep 16 15:19:14 2009 +0200 @@ -25,13 +25,18 @@ #include #include -extern "C" -{ +#ifdef __cplusplus +extern "C" { +#endif + #include "applicfg.h" #include "can_driver.h" #include "timer.h" #include "timers_driver.h" + +#ifdef __cplusplus }; +#endif struct _timeb timebuffer; @@ -142,7 +147,7 @@ LARGE_INTEGER liDueTime; /* arg 2 of SetWaitableTimer take 100 ns interval */ - liDueTime.QuadPart = -value; + liDueTime.QuadPart = (-1 * value); //printf("SetTimer(%llu)\n", value); if (!SetWaitableTimer(timer, &liDueTime, 0, NULL, NULL, FALSE)) diff -r aba1bf1defc6 -r 513f5ec8b628 drivers/win32/win32.c --- a/drivers/win32/win32.c Wed Sep 16 15:18:23 2009 +0200 +++ b/drivers/win32/win32.c Wed Sep 16 15:19:14 2009 +0200 @@ -26,12 +26,19 @@ */ #include -extern "C" -{ + +#ifdef __cplusplus +extern "C" { +#endif + #include "canfestival.h" #include "timer.h" #include "timers_driver.h" + +#ifdef __cplusplus }; +#endif + // GetProcAddress doesn't have an UNICODE version for NT #ifdef UNDER_CE #define myTEXT(str) TEXT(str) @@ -138,6 +145,8 @@ CAN_HANDLE canOpen(s_BOARD *board, CO_Data * d) { int i; + CAN_HANDLE fd0; + for(i=0; i < MAX_NB_CAN_PORTS; i++) { if(!canports[i].used) @@ -152,7 +161,7 @@ } #endif - CAN_HANDLE fd0 = m_canOpen(board); + fd0 = m_canOpen(board); if(fd0) { canports[i].used = 1; @@ -173,16 +182,24 @@ int canClose(CO_Data * d) { UNS8 res; - - ((CANPort*)d->canHandle)->used = 0; - CANPort* tmp = (CANPort*)d->canHandle; + CANPort* tmp; + + if((CANPort*)d->canHandle) + { + ((CANPort*)d->canHandle)->used = 0; + } + + tmp = (CANPort*)d->canHandle; d->canHandle = NULL; - // close CAN port - res = m_canClose(tmp->fd); - - // kill receiver task - WaitReceiveTaskEnd(&tmp->receiveTask); + if(tmp) + { + // close CAN port + res = m_canClose(tmp->fd); + + // kill receiver task + WaitReceiveTaskEnd(&tmp->receiveTask); + } return res; }