Skip to content

Commit

Permalink
Solve Additional Mingw-32 Compile Errors (#60)
Browse files Browse the repository at this point in the history
* Initial refactor of 'CMarkup::Format'.

* Updating syntax issues.

* Updating syntax issues.

* Saving.

* Some additional fixing, tested with ASAN to make sure the Heap buffer overflow issue is gone.

* Revert 'RTClientSDK.vcxproj' to original state.

* Update code to utilize 'std::string' instead.

* Remove extra indentation.

* Added comment.

* Remove Windows-only code, only use cross-platform version.

* Updated back to a if-windows solution to reintroduce usage of safer function calls when possible.

* Included 'cstdint' to rectify additional compile errors.

* Fix incorrect indentation.

* Fix incorrect indentation.

* Fix incorrect indentation.

* Remove duplicate code.

* Remove redundant comments.

* Replace tabs with spaces.

* Revert 'Markup.cpp' to master version.

* Move 'cstdint' from .cpp file to .h file.

* Change from c-include to cpp-include of 'stdint'.

* Remove include from 'RTPacket.h', add 'std::' to uint and int usages in RTProtocol.h for correctness.

* Change remaining usages of special int and uint for correctness.

* Add missed 'std::'.
  • Loading branch information
OliverGlandberger authored Jan 14, 2025
1 parent 034309c commit 28c8bf5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions RTClientExample/OutputSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,13 +965,13 @@ void COutput::PrintSkeletonSettings(CRTProtocol* poRTProtocol, bool skeletonGlob
for (unsigned int iSkeleton = 0; iSkeleton < poRTProtocol->GetSkeletonCount(); iSkeleton++)
{
CRTProtocol::SSettingsSkeletonHierarchical skeleton;
uint32_t level = 0;
std::uint32_t level = 0;

if ((majorVersion > 1 || minorVersion > 20) && poRTProtocol->GetSkeleton(iSkeleton, skeleton))
{
printf("\nSkeleton Name: %s Scale: %f", skeleton.name.c_str(), skeleton.scale);

std::function<void(const CRTProtocol::SSettingsSkeletonSegmentHierarchical, uint32_t&)> recurseSegments = [&](const CRTProtocol::SSettingsSkeletonSegmentHierarchical& segment, uint32_t& level)
std::function<void(const CRTProtocol::SSettingsSkeletonSegmentHierarchical, std::uint32_t&)> recurseSegments = [&](const CRTProtocol::SSettingsSkeletonSegmentHierarchical& segment, std::uint32_t& level)
{
level++;
std::string indent = std::string(level * 3, ' ');
Expand Down
1 change: 0 additions & 1 deletion RTPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include <memory.h>
#include <float.h>
#include <stdint.h>
#include <math.h>

#ifdef _WIN32
Expand Down
26 changes: 13 additions & 13 deletions RTProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3246,15 +3246,15 @@ namespace
return true;
}

bool TryReadSetColor(CMarkup& oXML, uint32_t& nTarget)
bool TryReadSetColor(CMarkup& oXML, std::uint32_t& nTarget)
{
if (!oXML.FindChildElem("Color"))
{
return false;
}
uint32_t colorR = atoi(oXML.GetChildAttrib("R").c_str());
uint32_t colorG = atoi(oXML.GetChildAttrib("G").c_str());
uint32_t colorB = atoi(oXML.GetChildAttrib("B").c_str());
std::uint32_t colorR = atoi(oXML.GetChildAttrib("R").c_str());
std::uint32_t colorG = atoi(oXML.GetChildAttrib("G").c_str());
std::uint32_t colorB = atoi(oXML.GetChildAttrib("B").c_str());
nTarget = (colorR & 0xff) | ((colorG << 8) & 0xff00) | ((colorB << 16) & 0xff0000);

return true;
Expand All @@ -3271,7 +3271,7 @@ namespace
return true;
}

bool TryReadSetMinMarkersInBody(CMarkup& oXML, uint32_t& nTarget)
bool TryReadSetMinMarkersInBody(CMarkup& oXML, std::uint32_t& nTarget)
{
if (!oXML.FindChildElem("MinimumMarkersInBody"))
{
Expand Down Expand Up @@ -3397,14 +3397,14 @@ namespace
void ReadSetRotations(CMarkup& oXML, CRTProtocol::SOrigin& oTarget)
{
char tmpStr[10];
for (uint32_t i = 0; i < 9; i++)
for (std::uint32_t i = 0; i < 9; i++)
{
sprintf(tmpStr, "R%u%u", (i / 3) + 1, (i % 3) + 1);
oTarget.rotation[i] = (float)atof(oXML.GetChildAttrib(tmpStr).c_str());
}
}

bool TryReadSetRGBColor(CMarkup& oXML, uint32_t& oTarget)
bool TryReadSetRGBColor(CMarkup& oXML, std::uint32_t& oTarget)
{
if (!oXML.FindChildElem("RGBColor"))
{
Expand Down Expand Up @@ -3539,7 +3539,7 @@ bool CRTProtocol::Read6DOFSettings(bool &bDataAvailable)
if (!TryReadSetDataOrigin(oXML, s6DOFBodySettings.origin)
|| !oXML.FindChildElem("Data_orientation")
|| s6DOFBodySettings.origin.type != atoi(oXML.GetChildData().c_str())
|| s6DOFBodySettings.origin.relativeBody != static_cast<uint32_t>(atoi(oXML.GetChildAttrib("Relative_body").c_str()))
|| s6DOFBodySettings.origin.relativeBody != static_cast<std::uint32_t>(atoi(oXML.GetChildAttrib("Relative_body").c_str()))
)
{ // Data Orientation, Origin Type / Relative Body --- REQUIRED
return false;
Expand Down Expand Up @@ -6076,7 +6076,7 @@ bool CRTProtocol::Set6DOFBodySettings(std::vector<SSettings6DOFBody> settings)
oXML.AddAttrib("Z", std::to_string(body.origin.position.fZ).c_str());
oXML.AddAttrib("Relative_body", std::to_string(body.origin.relativeBody).c_str());
oXML.AddElem("Data_orientation", std::to_string(body.origin.type).c_str());
for (uint32_t i = 0; i < 9; i++)
for (std::uint32_t i = 0; i < 9; i++)
{
char tmpStr[16];
sprintf(tmpStr, "R%u%u", (i / 3) + 1, (i % 3) + 1);
Expand Down Expand Up @@ -6253,8 +6253,8 @@ char* CRTProtocol::GetErrorString()

bool CRTProtocol::SendString(const char* pCmdStr, int nType)
{
uint32_t nCmdStrLen = (int)strlen(pCmdStr);
uint32_t nSize = 8 + nCmdStrLen + 1; // Header size + length of the string + terminating null char
std::uint32_t nCmdStrLen = (int)strlen(pCmdStr);
std::uint32_t nSize = 8 + nCmdStrLen + 1; // Header size + length of the string + terminating null char

if (nSize > mSendBuffer.size())
{
Expand Down Expand Up @@ -6498,7 +6498,7 @@ std::string CRTProtocol::ToLower(std::string str)
return str;
}

bool CRTProtocol::ParseString(const std::string& str, uint32_t& value)
bool CRTProtocol::ParseString(const std::string& str, std::uint32_t& value)
{
try
{
Expand All @@ -6511,7 +6511,7 @@ bool CRTProtocol::ParseString(const std::string& str, uint32_t& value)
return true;
}

bool CRTProtocol::ParseString(const std::string& str, int32_t& value)
bool CRTProtocol::ParseString(const std::string& str, std::int32_t& value)
{
try
{
Expand Down
35 changes: 18 additions & 17 deletions RTProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <map>
#include <limits>
#include <cmath>
#include <cstdint>

#ifdef _WIN32
#pragma warning (disable : 4251)
Expand Down Expand Up @@ -196,7 +197,7 @@ class DLL_EXPORT CRTProtocol
float fY;
float fZ;
bool virtual_;
uint32_t physicalId;
std::uint32_t physicalId;
};


Expand Down Expand Up @@ -305,7 +306,7 @@ class DLL_EXPORT CRTProtocol
{
}
bool bEnabled;
uint32_t nFrequency;
std::uint32_t nFrequency;
ETimestampType nType;
};

Expand Down Expand Up @@ -386,7 +387,7 @@ class DLL_EXPORT CRTProtocol
struct SOrigin
{
EOriginType type;
uint32_t relativeBody;
std::uint32_t relativeBody;
SPoint position;
float rotation[9];
};
Expand All @@ -395,10 +396,10 @@ class DLL_EXPORT CRTProtocol
{
std::string name;
bool enabled;
uint32_t color;
std::uint32_t color;
std::string filterPreset;
float maxResidual;
uint32_t minMarkersInBody;
std::uint32_t minMarkersInBody;
float boneLengthTolerance;
SSettings6DMesh mesh;
SOrigin origin;
Expand Down Expand Up @@ -479,10 +480,10 @@ class DLL_EXPORT CRTProtocol

struct SCalibrationFov
{
uint32_t left;
uint32_t top;
uint32_t right;
uint32_t bottom;
std::uint32_t left;
std::uint32_t top;
std::uint32_t right;
std::uint32_t bottom;
};

struct SCalibrationTransform
Expand Down Expand Up @@ -525,11 +526,11 @@ class DLL_EXPORT CRTProtocol
bool active;
bool calibrated;
std::string message;
uint32_t point_count;
std::uint32_t point_count;
double avg_residual;
uint32_t serial;
std::uint32_t serial;
std::string model;
uint32_t view_rotation;
std::uint32_t view_rotation;
SCalibrationFov fov_marker;
SCalibrationFov fov_marker_max;
SCalibrationFov fov_video;
Expand All @@ -554,14 +555,14 @@ class DLL_EXPORT CRTProtocol
ECalibrationType type = regular;
double refit_residual = std::numeric_limits<double>::quiet_NaN(); // Only for refine calibration.
double wand_length = std::numeric_limits<double>::quiet_NaN(); // Not for fixed calibration.
uint32_t max_frames = 0; // Not for fixed calibration.
std::uint32_t max_frames = 0; // Not for fixed calibration.
double short_arm_end = std::numeric_limits<double>::quiet_NaN(); // Not for fixed calibration.
double long_arm_end = std::numeric_limits<double>::quiet_NaN(); // Not for fixed calibration.
double long_arm_middle = std::numeric_limits<double>::quiet_NaN(); // Not for fixed calibration.
double result_std_dev = std::numeric_limits<double>::quiet_NaN(); // Not for fixed calibration.
double result_min_max_diff = std::numeric_limits<double>::quiet_NaN(); // Not for fixed calibration.
double result_refit_residual = std::numeric_limits<double>::quiet_NaN(); // Only for refine calibration.
uint32_t result_consecutive = 0; // Only for refine calibration.
std::uint32_t result_consecutive = 0; // Only for refine calibration.
std::vector<SCalibrationCamera> cameras;
};

Expand Down Expand Up @@ -636,7 +637,7 @@ class DLL_EXPORT CRTProtocol
struct SSettingsSkeletonSegmentHierarchical
{
std::string name;
uint32_t id = 0;
std::uint32_t id = 0;
std::string solver;
SPosition position;
SRotation rotation;
Expand Down Expand Up @@ -945,8 +946,8 @@ class DLL_EXPORT CRTProtocol
bool CompareNoCase(std::string tStr1, const char* tStr2) const;
bool ReceiveCalibrationSettings(int timeout = cWaitForDataTimeout);
static std::string ToLower(std::string str);
static bool ParseString(const std::string& str, uint32_t& value);
static bool ParseString(const std::string& str, int32_t& value);
static bool ParseString(const std::string& str, std::uint32_t& value);
static bool ParseString(const std::string& str, std::int32_t& value);
static bool ParseString(const std::string& str, float& value);
static bool ParseString(const std::string& str, double& value);
static bool ParseString(const std::string& str, bool& value);
Expand Down

0 comments on commit 28c8bf5

Please sign in to comment.