Skip to content

Commit

Permalink
Fixed isnan compil error for MSVC/GCC
Browse files Browse the repository at this point in the history
  • Loading branch information
plstcharles committed Jan 13, 2016
1 parent 9a2117b commit 92ee344
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
12 changes: 12 additions & 0 deletions modules/utils/include/litiv/utils/CxxUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,21 @@ namespace CxxUtils {
getRandNeighborPosition<24>(s_anNeighborPattern,nNeighborCoord_X,nNeighborCoord_Y,nOrigCoord_X,nOrigCoord_Y,nBorderSize,oImageSize);
}

template<typename T>
static inline bool isnan(T dVal) {
// needed for portability...
#ifdef _MSC_VER
return _isnan((double)dVal)!=0;
#else //!def(_MSC_VER)
return std::isnan(dVal);
#endif //!def(_MSC_VER)
}

} //namespace CxxUtils

namespace std {

template<typename T, size_t N>
using aligned_vector = vector<T,CxxUtils::AlignAllocator<T,N>>;

} //namespace std
3 changes: 0 additions & 3 deletions modules/utils/include/litiv/utils/DefineUtils.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@
#ifndef R2D
#define R2D(r) ((r)*(180.0/M_PI))
#endif //ndefined(R2D)
#ifndef isnan
#define isnan(f) std::isnan(f)
#endif //ndefined(isnan)
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif //ndefined(__STDC_FORMAT_MACROS)
Expand Down
13 changes: 10 additions & 3 deletions modules/vptz/include/litiv/vptz/StandaloneUtils.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@
#ifndef R2D
#define R2D(r) ((r)*(180.0/M_PI))
#endif //ndefined(R2D)
#ifndef isnan
#define isnan(f) std::isnan(f)
#endif //ndefined(isnan)

#if defined(_MSC_VER)
#ifndef NOMINMAX
Expand Down Expand Up @@ -176,6 +173,16 @@ namespace CxxUtils {
}
};

template<typename T>
static inline bool isnan(T dVal) {
// needed for portability...
#ifdef _MSC_VER
return _isnan((double)dVal)!=0;
#else //!def(_MSC_VER)
return std::isnan(dVal);
#endif //!def(_MSC_VER)
}

} //namespace CxxUtils

#define TARGET_GL_VER_MAJOR 3
Expand Down
2 changes: 1 addition & 1 deletion modules/vptz/src/virtualptz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ vptz::Camera::Camera( const std::string& sInputPath, double verti_FOV, double ou
vptzErrorExt("cannot open the input panomaric video file at %s",m_sInputPath.c_str());
m_nScenarioFrameCount = (int)panoCapture.get(cv::CAP_PROP_FRAME_COUNT);
m_dFrameRate = panoCapture.get(cv::CAP_PROP_FPS);
if(m_dFrameRate<=0 || isnan(m_dFrameRate)) {
if(m_dFrameRate<=0 || CxxUtils::isnan(m_dFrameRate)) {
std::cerr << "VirtualPTZ Warning : could not determine frame rate for input video; check container support on platform" << std::endl;
m_dFrameRate = 16.0;
}
Expand Down

0 comments on commit 92ee344

Please sign in to comment.