Skip to content

Commit

Permalink
Fix build issues and warnings on uwp
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Sep 20, 2024
1 parent 47c4a2d commit 4ffa1ba
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 39 deletions.
6 changes: 5 additions & 1 deletion modules/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,8 @@ vp_glob_module_copy_data("test/math/data/*.pgm" "modules/core" NO_INSTALL)
# copy font
vp_glob_module_copy_data("src/image/private/Rubik-Regular.ttf" "data/font")

vp_set_source_file_compile_flag(src/tools/file/vpIoTools_npy.cpp -Wno-misleading-indentation)
if(UNIX)
vp_set_source_file_compile_flag(src/tools/file/vpIoTools_npy.cpp -Wno-misleading-indentation)
else()
vp_set_source_file_compile_flag(src/tools/file/vpIoTools_npy.cpp /wd4333)
endif()
4 changes: 2 additions & 2 deletions modules/core/src/math/random-generator/vpUniRand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ uint32_t vpUniRand::boundedRand(uint32_t bound)
// because this version will calculate the same modulus, but the LHS
// value is less than 2^32.

uint32_t threshold = -bound % bound;
uint32_t threshold = static_cast<uint64_t>(-static_cast<int64_t>(bound) % bound);

// Uniformity guarantees that this loop will terminate. In practice, it
// should usually terminate quickly; on average (assuming all bounds are
Expand All @@ -148,7 +148,7 @@ uint32_t vpUniRand::next()
m_rng.state = (oldstate * 6364136223846793005ULL) + m_rng.inc;
uint32_t xorshifted = static_cast<uint32_t>(((oldstate >> 18u) ^ oldstate) >> 27u);
uint32_t rot = oldstate >> 59u;
return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
return (xorshifted >> rot) | (xorshifted << (static_cast<uint32_t>((-static_cast<int64_t>(rot)) & 31)));
}

/*!
Expand Down
46 changes: 25 additions & 21 deletions modules/core/src/tools/network/vpClient.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/****************************************************************************
*
/*
* ViSP, open source Visual Servoing Platform software.
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
*
Expand Down Expand Up @@ -30,17 +29,22 @@
*
* Description:
* TCP Client
*
* Authors:
* Aurelien Yol
*
*****************************************************************************/
*/

#include <visp3/core/vpClient.h>
#include <visp3/core/vpConfig.h>

// Specific case for UWP to introduce a workaround
// error C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
#if defined(WINRT)
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif

// inet_ntop() not supported on win XP
#ifdef VISP_HAVE_FUNC_INET_NTOP

#include <visp3/core/vpClient.h>
#include <visp3/core/vpDebug.h>

BEGIN_VISP_NAMESPACE
Expand Down Expand Up @@ -97,18 +101,18 @@ bool vpClient::connectToHostname(const std::string &hostname, const unsigned int
serv.receptorIP = inet_ntoa(*(in_addr *)server->h_addr);

return connectServer(serv);
}
}

/*!
Connect to the server represented by the given ip, and at a given port.
/*!
Connect to the server represented by the given ip, and at a given port.
\sa vpClient::connectToHostname()
\sa vpClient::connectToHostname()
\param ip : IP of the server.
\param port_serv : Port used for the connection.
\param ip : IP of the server.
\param port_serv : Port used for the connection.
\return True if the connection has been etablished, false otherwise.
*/
\return True if the connection has been etablished, false otherwise.
*/
bool vpClient::connectToIP(const std::string &ip, const unsigned int &port_serv)
{
vpNetwork::vpReceptor serv;
Expand All @@ -130,13 +134,13 @@ bool vpClient::connectToIP(const std::string &ip, const unsigned int &port_serv)
serv.receptorAddress.sin_port = htons((unsigned short)port_serv);

return connectServer(serv);
}
}

/*!
Deconnect from the server at a specific index.
/*!
Deconnect from the server at a specific index.
\param index : Index of the server.
*/
\param index : Index of the server.
*/
void vpClient::deconnect(const unsigned int &index)
{
if (index < receptor_list.size()) {
Expand Down
20 changes: 12 additions & 8 deletions modules/core/src/tools/network/vpNetwork.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/****************************************************************************
*
/*
* ViSP, open source Visual Servoing Platform software.
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
*
Expand Down Expand Up @@ -30,17 +29,22 @@
*
* Description:
* TCP Network
*
* Authors:
* Aurelien Yol
*
*****************************************************************************/
*/

#include <visp3/core/vpNetwork.h>
#include <visp3/core/vpConfig.h>

// Specific case for UWP to introduce a workaround
// error C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
#if defined(WINRT)
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif

// inet_ntop() not supported on win XP
#ifdef VISP_HAVE_FUNC_INET_NTOP

#include <visp3/core/vpNetwork.h>
#include <visp3/core/vpDebug.h>
BEGIN_VISP_NAMESPACE
vpNetwork::vpNetwork()
Expand Down
19 changes: 13 additions & 6 deletions modules/core/src/tools/network/vpServer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/****************************************************************************
*
/*
* ViSP, open source Visual Servoing Platform software.
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
*
Expand Down Expand Up @@ -30,16 +29,24 @@
*
* Description:
* TCP Server
*
*****************************************************************************/
*/

#include <visp3/core/vpServer.h>
#include <visp3/core/vpConfig.h>

#include <sstream>
// Specific case for UWP to introduce a workaround
// error C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
#if defined(WINRT)
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif

// inet_ntop() not supported on win XP
#ifdef VISP_HAVE_FUNC_INET_NTOP

#include <sstream>

#include <visp3/core/vpServer.h>
#include <visp3/core/vpDebug.h>

#if defined(__APPLE__) && defined(__MACH__) // Apple OSX and iOS (Darwin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void vpLuminanceDCT::inverse(const vpColVector &s, vpImage<unsigned char> &I)
I.resize(Ir.getRows(), Ir.getCols());
for (unsigned int i = 0; i < I.getRows(); ++i) {
for (unsigned int j = 0; j < I.getCols(); ++j) {
I[i][j] = std::max(0.0, std::min(Ir[i][j], 255.0));
I[i][j] = static_cast<unsigned char>(std::max(0.0, std::min(Ir[i][j], 255.0)));
}
}
}
Expand Down

0 comments on commit 4ffa1ba

Please sign in to comment.