Skip to content

Commit

Permalink
Improved MSVC support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kestred committed Oct 4, 2014
1 parent 39608dd commit 6b8a531
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
### Define extra windows defines ###
if(WIN32)
add_definitions(-D_WIN32_WINDOWS)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
endif()

### Set build type to Release with Debug Info by default ###
Expand Down Expand Up @@ -413,6 +415,7 @@ source_group("Core" FILES ${CORE_FILES})
source_group("Config" FILES ${CONFIG_FILES})
source_group("Util" FILES ${UTIL_FILES})
source_group("MessageDirector" FILES ${MESSAGEDIRECTOR_FILES})
source_group("Net" FILES ${NET_FILES})
if(STATESERVER_FILES)
add_definitions(-DBUILD_STATESERVER)
source_group("StateServer" FILES ${STATESERVER_FILES})
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/FindYamlCpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# YAMLCPP_LIBRARY_DIR, the directory containing YAML_LIBRARY
#
# By default, the dynamic libraries of yaml-cpp will be found. To find the static ones instead,
# you must set the YAMLCPP_USE_STATIC_LIBS variable to TRUE before calling find_package(YamlCpp ...).
# you must set the YAMLCPP_USE_STATIC_LIBS variable to TRUE before calling find_package(YamlCpp ...)

# attempt to find static library first if this is set
if(YAMLCPP_USE_STATIC_LIBS)
Expand All @@ -31,7 +31,7 @@ find_path(YAMLCPP_INCLUDE_DIR yaml-cpp/yaml.h
# find the yaml-cpp library
find_library(YAMLCPP_LIBRARY
NAMES ${YAMLCPP_STATIC} yaml-cpp libyaml-cppmd.lib
PATH_SUFFIXES lib64 lib
PATH_SUFFIXES lib64 lib ${CMAKE_BUILD_TYPE}
PATHS ~/Library/Frameworks
/Library/Frameworks
/usr/local
Expand Down
2 changes: 1 addition & 1 deletion src/clientagent/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void Client::build_interest(DatagramIterator &dgi, bool multiple, Interest &out)

// TODO: We shouldn't have to do this ourselves, figure out where else we're doing
// something wrong.
out.zones.rehash(ceil(count / out.zones.max_load_factor()));
out.zones.rehash((unsigned int)(ceil(count / out.zones.max_load_factor())));

for(int x = 0; x < count; ++x) {
zone_t zone = dgi.read_zone();
Expand Down
2 changes: 1 addition & 1 deletion src/dclass/file/hash_legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void hash_int_type(HashGenerator& hashgen, const NumericType* numeric)
{
hashgen.add_int(numeric->get_divisor());
if(numeric->has_modulus()) {
unsigned int modulus = floor(numeric->get_modulus() * numeric->get_divisor() + 0.5);
unsigned int modulus = (unsigned int)floor(numeric->get_modulus() * numeric->get_divisor() + 0.5);
hashgen.add_int(int(modulus));
}
if(numeric->has_range()) {
Expand Down
2 changes: 1 addition & 1 deletion src/dclass/value/default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ string create_default_value(const DistributedType* dtype, bool& is_implicit)
case T_STRING: {
const ArrayType* array = dtype->as_array();
uint64_t min_array_elements = array->get_range().min.uinteger;
return string(min_array_elements, '\0');
return string((unsigned int)min_array_elements, '\0');
}
case T_VARARRAY:
case T_VARBLOB:
Expand Down
13 changes: 9 additions & 4 deletions src/dclass/value/format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include "dc/Parameter.h"
#include "util/byteorder.h"

#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1800
#define snprintf sprintf_s
#endif


#include "format.h"
using namespace std;
namespace dclass // open namespace dclass
Expand Down Expand Up @@ -88,7 +93,7 @@ struct Formatter {
if(!remaining(sizeof(int64_t))) {
return false;
}
int v = swap_le(*(int64_t*)(in + offset));
int64_t v = swap_le(*(int64_t*)(in + offset));
offset += sizeof(int64_t);
out << v;
break;
Expand Down Expand Up @@ -124,7 +129,7 @@ struct Formatter {
if(!remaining(sizeof(uint64_t))) {
return false;
}
unsigned int v = swap_le(*(uint64_t*)(in + offset));
uint64_t v = swap_le(*(uint64_t*)(in + offset));
offset += sizeof(uint64_t);
out << v;
break;
Expand Down Expand Up @@ -514,7 +519,7 @@ void format_hex(const string &str, ostream &out)
out << '<';
for(auto it = str.begin(); it != str.end(); ++it) {
char infer[10];
sprintf(infer, "%02x", (unsigned char)(*it));
snprintf(infer, 10, "%02x", (unsigned char)(*it));
out << infer;
}
out << '>';
Expand All @@ -541,7 +546,7 @@ void format_quoted(char quote_mark, const string &str, ostream &out)
} else if(!isprint(c)) { // character is not a printable ascii character
// print the character as an escaped hexidecimal character constant
char infer[10];
sprintf(infer, "%02x", (unsigned char)c);
snprintf(infer, 10, "%02x", (unsigned char)c);
out << "\\x" << infer;
} else {
out << c;
Expand Down
2 changes: 1 addition & 1 deletion src/messagedirector/MDNetworkParticipant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void MDNetworkParticipant::handle_datagram(DatagramHandle dg, DatagramIterator&)
logger().trace() << "MDNetworkParticipant sending to downstream MD" << std::endl;
try {
send_datagram(dg);
} catch(const boost::system::system_error &e) {
} catch(const boost::system::system_error &) {
logger().warning() << "Received a system error while sending a datagram to a network "
"participant (the participant may have lost connection)." << std::endl;
return;
Expand Down

0 comments on commit 6b8a531

Please sign in to comment.