Skip to content

Commit

Permalink
Use more reliable Windows macro: WIN32 --> _WIN32
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Aug 11, 2015
1 parent 15dd9d1 commit 6118b37
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions dart/common/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Timer::Timer(const std::string& _name)
mName(_name),
mIsStarted(false)
{
#if WIN32
#ifdef _WIN32
mTimer.start.QuadPart = 0;
mTimer.stop.QuadPart = 0;
QueryPerformanceFrequency(&mFrequency);
Expand All @@ -71,7 +71,7 @@ Timer::~Timer()
}

//==============================================================================
#if WIN32
#ifdef _WIN32
double Timer::_convLIToSecs(const LARGE_INTEGER& _L)
{
return (static_cast<double>(_L.QuadPart)
Expand All @@ -84,7 +84,7 @@ void Timer::start()
{
mIsStarted = true;
mCount++;
#if WIN32
#ifdef _WIN32
QueryPerformanceCounter(&mTimer.start);
#else
gettimeofday(&mTimeVal, nullptr);
Expand All @@ -96,7 +96,7 @@ void Timer::start()
void Timer::stop()
{
mIsStarted = false;
#if WIN32
#ifdef _WIN32
QueryPerformanceCounter(&mTimer.stop);
LARGE_INTEGER time;
time.QuadPart = mTimer.stop.QuadPart - mTimer.start.QuadPart;
Expand All @@ -112,7 +112,7 @@ void Timer::stop()
//==============================================================================
double Timer::getElapsedTime()
{
#if WIN32
#ifdef _WIN32
LARGE_INTEGER timenow;
QueryPerformanceCounter(&timenow);
LARGE_INTEGER time;
Expand Down Expand Up @@ -166,7 +166,7 @@ void Timer::print()
//==============================================================================
double Timer::getWallTime()
{
#if WIN32
#ifdef _WIN32
LARGE_INTEGER ticksPerSecond;
LARGE_INTEGER ticks;
QueryPerformanceFrequency(&ticksPerSecond);
Expand Down
6 changes: 3 additions & 3 deletions dart/common/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

#include <string>

#if WIN32
#ifdef _WIN32
#ifdef NOMINMAX
#include <windows.h>
#else
Expand Down Expand Up @@ -100,7 +100,7 @@ class Timer
private:
int mCount;

#if WIN32
#ifdef _WIN32
stopWatch mTimer;
#else
timeval mTimeVal;
Expand All @@ -113,7 +113,7 @@ class Timer
std::string mName;
bool mIsStarted;

#if WIN32
#ifdef _WIN32
LARGE_INTEGER mFrequency;
double _convLIToSecs(const LARGE_INTEGER& _L);
#endif
Expand Down
4 changes: 2 additions & 2 deletions dart/gui/GlutWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#include "dart/gui/GlutWindow.h"

#ifndef WIN32
#ifndef _WIN32
#include <dirent.h>
#endif
#include <cstdio>
Expand Down Expand Up @@ -153,7 +153,7 @@ bool GlutWindow::screenshot() {
char fileBase[32] = "frames/Capture";
char fileName[64];
// png
#ifdef WIN32
#ifdef _WIN32
_snprintf(fileName, sizeof(fileName), "%s%.4d.png", fileBase, count++);
#else
std::snprintf(fileName, sizeof(fileName), "%s%.4d.png", fileBase, count++);
Expand Down
4 changes: 2 additions & 2 deletions dart/gui/GraphWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void GraphWindow::draw() {
while (xPos < 1.0) {
char buff[64];
int v = xPos * nPoints;
#ifdef WIN32
#ifdef _WIN32
_snprintf(buff, sizeof(buff), "%d", v);
#else
std::snprintf(buff, sizeof(buff), "%d", v);
Expand All @@ -106,7 +106,7 @@ void GraphWindow::draw() {
while (yPos < 1.0) {
char buff[64];
double v = yPos * (upperBound - lowerBound) + lowerBound;
#ifdef WIN32
#ifdef _WIN32
_snprintf(buff, sizeof(buff), "%.2e", v);
#else
std::snprintf(buff, sizeof(buff), "%.2e", v);
Expand Down
2 changes: 1 addition & 1 deletion dart/gui/LoadGlut.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#ifndef DART_GUI_LOADGLUT_H_
#define DART_GUI_LOADGLUT_H_

#if WIN32
#ifdef _WIN32
#include <cstdlib> // To disable glut::exit() function
#include <GL/glut.h>
#elif defined(__linux__)
Expand Down
4 changes: 2 additions & 2 deletions dart/gui/SimWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ void SimWindow::draw() {
// display the frame count in 2D text
char buff[64];
if (!mSimulating)
#ifdef WIN32
#ifdef _WIN32
_snprintf(buff, sizeof(buff), "%d", mPlayFrame);
#else
std::snprintf(buff, sizeof(buff), "%d", mPlayFrame);
#endif
else
#ifdef WIN32
#ifdef _WIN32
_snprintf(buff, sizeof(buff), "%d", mWorld->getSimFrames());
#else
std::snprintf(buff, sizeof(buff), "%d", mWorld->getSimFrames());
Expand Down
4 changes: 2 additions & 2 deletions dart/lcpsolver/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void printMessage (int num, const char *msg1, const char *msg2,
//****************************************************************************
// unix

#ifndef WIN32
#ifndef _WIN32

extern "C" void dError (int num, const char *msg, ...)
{
Expand Down Expand Up @@ -117,7 +117,7 @@ extern "C" void dMessage (int num, const char *msg, ...)
//****************************************************************************
// windows

#ifdef WIN32
#ifdef _WIN32

// isn't cygwin annoying!
#ifdef CYGWIN
Expand Down
4 changes: 2 additions & 2 deletions dart/math/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ inline bool isInt(double _x) {

/// \brief Returns whether _v is a NaN (Not-A-Number) value
inline bool isNan(double _v) {
#ifdef WIN32
#ifdef _WIN32
return _isnan(_v);
#else
return std::isnan(_v);
Expand All @@ -173,7 +173,7 @@ inline bool isNan(const Eigen::MatrixXd& _m) {
/// \brief Returns whether _v is an infinity value (either positive infinity or
/// negative infinity).
inline bool isInf(double _v) {
#ifdef WIN32
#ifdef _WIN32
return !_finite(_v);
#else
return std::isinf(_v);
Expand Down
2 changes: 1 addition & 1 deletion dart/renderer/LoadOpengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#ifndef DART_RENDERER_LOADOPENGL_H_
#define DART_RENDERER_LOADOPENGL_H_

#if WIN32
#ifdef _WIN32
#ifdef NOMINMAX
#include <windows.h>
#else
Expand Down
4 changes: 2 additions & 2 deletions unittests/testCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ TEST(Common, Timer)
for (int i = 0; i < 1e+3; ++i)
{
timer2.start();
#ifdef WIN32
#ifdef _WIN32
Sleep(2); // 2 milliseconds
#else
usleep(2000); // 2 milliseconds
Expand All @@ -64,7 +64,7 @@ TEST(Common, Timer)
timer2.print();

// Both timer should have counted more than 2 seconds
#ifdef WIN32
#ifdef _WIN32
// On Windows, Sleep(2) takes less than exact 2 milliseconds..
EXPECT_GE(timer1.getTotalElapsedTime(), 1.99);
EXPECT_GE(timer2.getTotalElapsedTime(), 1.99);
Expand Down

0 comments on commit 6118b37

Please sign in to comment.