diff --git a/examples/pinproctest/pinproctest.cpp b/examples/pinproctest/pinproctest.cpp index 3220f0d..ab75ac2 100644 --- a/examples/pinproctest/pinproctest.cpp +++ b/examples/pinproctest/pinproctest.cpp @@ -115,7 +115,7 @@ void RunLoop(PRHandle proc) case kPREventTypeSwitchOpenNondebounced: stateText = "open(ndb)"; break; case kPREventTypeSwitchClosedNondebounced: stateText = "closed(ndb)"; break; } -#ifdef _VC_ +#ifdef _MSC_VER struct _timeb tv; _ftime(&tv); #else @@ -130,7 +130,7 @@ void RunLoop(PRHandle proc) case kPREventTypeSwitchOpenNondebounced: case kPREventTypeSwitchClosedNondebounced: { -#ifdef _VC_ +#ifdef _MSC_VER printf("%d.%03d switch % 3d: %s\n", tv.time-startTime, tv.millitm, event->value, stateText); #else printf("%d.%03d switch % 3d: %s\n", (int)(tv.tv_sec-startTime), (int)tv.tv_usec/1000, event->value, stateText); @@ -152,7 +152,7 @@ void RunLoop(PRHandle proc) } } PRFlushWriteData(proc); -#ifdef _VC_ +#ifdef _MSC_VER Sleep(10); #else usleep(10*1000); // Sleep for 10ms so we aren't pegging the CPU. diff --git a/examples/pinproctest/pinproctest.h b/examples/pinproctest/pinproctest.h index da63d17..6a9bc67 100644 --- a/examples/pinproctest/pinproctest.h +++ b/examples/pinproctest/pinproctest.h @@ -31,16 +31,16 @@ #include #include -#ifndef _VC_ - #include +#ifndef _MSC_VER +#include #endif #include -#include "../../include/pinproc.h" // Include libpinproc's header. +#include "pinproc.h" // Include libpinproc's header. #include #include -#ifdef _VC_ +#ifdef _MSC_VER #include #include #include diff --git a/include/pinproc.h b/include/pinproc.h index 329891c..a5ee89d 100644 --- a/include/pinproc.h +++ b/include/pinproc.h @@ -31,10 +31,16 @@ #ifndef _PINPROC_H_ #define _PINPROC_H_ +/* + * 3rd party "stdint.h" replacement available for Visual C++ before version 2010. + * http://en.wikipedia.org/wiki/Stdint.h#External_links + * -> http://msinttypes.googlecode.com/svn/trunk/stdint.h + * Place inside the major include dir (e.g. %ProgramFiles%\Microsoft Visual Studio\VC98\INCLUDE) + */ #include /** @cond */ -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(_WIN32) #undef PR_EXPORT #if defined(PR_BUILDING_PR) #define PR_EXPORT __declspec(dllexport) extern diff --git a/src/PRDevice.cpp b/src/PRDevice.cpp index 9ef28ae..f908659 100644 --- a/src/PRDevice.cpp +++ b/src/PRDevice.cpp @@ -31,7 +31,9 @@ #include "PRDevice.h" #include #include +#ifndef _MSC_VER #include +#endif #ifndef __WIND32__ #include #endif @@ -173,13 +175,13 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents) unrequestedDataQueue.pop(); events[i].value = event_data & P_ROC_EVENT_SWITCH_NUM_MASK; - bool open = (event_data & P_ROC_EVENT_SWITCH_STATE_MASK) >> P_ROC_EVENT_SWITCH_STATE_SHIFT; + int open = (event_data & P_ROC_EVENT_SWITCH_STATE_MASK) >> P_ROC_EVENT_SWITCH_STATE_SHIFT; switch ((event_data & P_ROC_EVENT_TYPE_MASK) >> P_ROC_EVENT_TYPE_SHIFT) { case P_ROC_EVENT_TYPE_SWITCH: { - bool debounced = (event_data & P_ROC_EVENT_SWITCH_DEBOUNCED_MASK) >> P_ROC_EVENT_SWITCH_DEBOUNCED_SHIFT; + int debounced = (event_data & P_ROC_EVENT_SWITCH_DEBOUNCED_MASK) >> P_ROC_EVENT_SWITCH_DEBOUNCED_SHIFT; if (open) events[i].type = debounced ? kPREventTypeSwitchOpenDebounced : kPREventTypeSwitchOpenNondebounced; else @@ -624,8 +626,9 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR // Now let's setup the first actual rule: uint16_t firstRuleIndex = newRuleIndex; PRSwitchRuleInternal *newRule = GetSwitchRuleByIndex(newRuleIndex); - if (newRule->eventType != eventType) + if (newRule->eventType != eventType) { DEBUG(PRLog(kPRLogWarning, "Unexpected state: switch rule at 0x%x has event type 0x%x (expected 0x%x).\n", newRuleIndex, newRule->eventType, eventType)); + } newRule->notifyHost = rule->notifyHost; newRule->reloadActive = rule->reloadActive; newRule->changeOutput = false; @@ -943,8 +946,9 @@ PRResult PRDevice::Open() res = FlushReadBuffer(); PRSleep(100); res = VerifyChipID(); - if (res == kPRFailure) + if (res == kPRFailure) { DEBUG(PRLog(kPRLogWarning, "Unable to read Chip ID - P-ROC could not be initialized.\n")); + } } } diff --git a/src/PRDevice.h b/src/PRDevice.h index deb581f..6a7d3a7 100644 --- a/src/PRDevice.h +++ b/src/PRDevice.h @@ -28,7 +28,7 @@ * libpinproc */ -#include "../include/pinproc.h" +#include "pinproc.h" #include "PRCommon.h" #include "PRHardware.h" #include diff --git a/src/PRHardware.cpp b/src/PRHardware.cpp index b87e105..85aa879 100644 --- a/src/PRHardware.cpp +++ b/src/PRHardware.cpp @@ -347,7 +347,7 @@ int32_t CreateJTAGShiftTDODataBurst ( uint32_t * burst, uint16_t numBits, bool_t * As we add support for other drivers (such as D2xx on Windows), we will add more implementations of the PRHardware*() functions here. */ -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(_WIN32) #define USE_D2XX 1 #endif @@ -576,7 +576,7 @@ int PRHardwareWrite(uint8_t *buffer, int bytes) if (ftStatus == FT_OK) { DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes:\n",bytesWritten)); - if (bytesWritten != bytes) DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes, should have written %d bytes",bytesWritten,bytes)); + if (bytesWritten != DWORD(bytes)) DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes, should have written %d bytes",bytesWritten,bytes)); else { for (i=0; (DWORD)i -#include "../include/pinproc.h" +#include "pinproc.h" -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(_WIN32) #include #define PRSleep(milliseconds) Sleep(milliseconds) #else diff --git a/src/pinproc.cpp b/src/pinproc.cpp index 9cf085c..a6afe7b 100644 --- a/src/pinproc.cpp +++ b/src/pinproc.cpp @@ -35,6 +35,10 @@ #include #include "PRDevice.h" +#if defined(_MSC_VER) && (_MSC_VER < 1300) +#define vsnprintf _vsnprintf +#endif + #define MAX_TEXT (1024) typedef void (*PRLogCallback)(PRLogLevel level, const char *text); diff --git a/utils/pinprocfw/pinprocfw.cpp b/utils/pinprocfw/pinprocfw.cpp index ed61b04..b6ea881 100644 --- a/utils/pinprocfw/pinprocfw.cpp +++ b/utils/pinprocfw/pinprocfw.cpp @@ -29,14 +29,15 @@ #include #include #include - #include #endif /* DEBUG_MODE */ #include "pinprocfw.h" #include "lenval.h" +#ifndef _MSC_VER #include +#endif -#include "../../include/pinproc.h" // Include libpinproc's header. +#include "pinproc.h" // Include libpinproc's header. PRMachineType machineType = kPRMachineCustom; // Should work with all machines. /*============================================================================ diff --git a/utils/pinprocfw/pinprocfw.h b/utils/pinprocfw/pinprocfw.h index 27f0c5b..de4dddf 100644 --- a/utils/pinprocfw/pinprocfw.h +++ b/utils/pinprocfw/pinprocfw.h @@ -13,7 +13,7 @@ #ifndef PINPROCFW_H #define PINPROCFW_H -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(_WIN32) #include #define PRSleep(milliseconds) Sleep(milliseconds) #else