Skip to content

Commit

Permalink
Fix MSVC not knowing about u_char and clang++ warning about double.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristomu committed Aug 3, 2024
1 parent e18761b commit 60e9621
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
if (MSVC)
# I'm not too sure about fp:fast? The docs seem to say that it doesn't
# invalidate non-finite floating point values, so it appears to be OK?

# The following warnings have been disabled:

# Warning C4464: relative paths in include
# I should fix these, but I don't want them spamming up
# the console before I do.

# Warning C4100: unused function parameter
# Fixing these would clutter up function definitions that
# have a common template, e.g. int foo(int bar) would have
# to be turned into int foo(int /*bar*/) whenever we don't
# use the bar paramete. That's too ugly, so I'm removing this.

# Warning C4127: conditional expression is constant
# Triggered by external libraries and thus not something we
# can do anything about.

# Warning C4244: implicit conversion may lead to loss of data
# Mostly size_t/int problems. Fixing them is going to take a
# lot of time and I don't want them spamming up the console
Expand Down
4 changes: 2 additions & 2 deletions src/ballots.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <map>

const size_t SIZE_T_NA = (size_t)-1;

const double DOUBLE_NA = -1;

// Ballot components. An ordering is just that, but it also includes ratings
// (if so declared), so that loser-elimination/average-elimination can work,
Expand Down Expand Up @@ -161,7 +161,7 @@ class ballot_group {
}

void replace_score(size_t candidate_number, double new_score) {
candscore this_cddt(SIZE_T_NA, SIZE_T_NA);
candscore this_cddt(SIZE_T_NA, DOUBLE_NA);
bool found_candidate = false;
for (candscore cs: contents) {
if (cs.get_candidate_num() == candidate_number) {
Expand Down
2 changes: 2 additions & 0 deletions src/modes/barycentric.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "../spookyhash/SpookyV2.h"

typedef unsigned char u_char; // not supported by MSVC

// Turns a string of the type "ABC" into a ranked ballot corresponding
// to A>B>C.
ordering strict_ballot(std::string input) {
Expand Down

0 comments on commit 60e9621

Please sign in to comment.