From 9f685c302a52f0801ca2f03fc03db3cae61ad3e9 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 24 Jan 2022 22:33:31 +0100 Subject: refactor: fix compiler warnings --- src/maze.tpp | 6 ++++-- src/mazerator.cpp | 4 ++-- src/stack.hpp | 6 ++---- src/stack.tpp | 2 +- src/utils.cpp | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/maze.tpp b/src/maze.tpp index 6c4fd71..84c273e 100644 --- a/src/maze.tpp +++ b/src/maze.tpp @@ -111,8 +111,10 @@ void matrix_to_maze(Matrix *matrix, std::shared_ptr start_pos, visited_pos_cnt++; - auto random_dist = - std::uniform_int_distribution(0U, neighbours.size() - 1UL); + auto random_dist = std::uniform_int_distribution( + 0U, + static_cast(neighbours.size()) - 1U + ); auto next_pos = neighbours[random_dist(random_gen)]; diff --git a/src/mazerator.cpp b/src/mazerator.cpp index f74f952..a82bbaf 100644 --- a/src/mazerator.cpp +++ b/src/mazerator.cpp @@ -8,7 +8,7 @@ #include #include -void optarg_error(char arg, std::string error) +void optarg_error(int arg, std::string error) { std::cout << "Error: Invalid option argument for -" << arg << ". " << error << std::endl; @@ -33,7 +33,7 @@ void validate_start_coords(unsigned int start_x, unsigned int start_y, unsigned * @param arg The command-line argument character * @param check_zero Whether or not to make sure that the result is not zero */ -void parse_uint_arg(unsigned int *num_dst, char arg, bool check_zero = false) +void parse_uint_arg(unsigned int *num_dst, int arg, bool check_zero = false) { try { diff --git a/src/stack.hpp b/src/stack.hpp index b156242..d5c1bdb 100644 --- a/src/stack.hpp +++ b/src/stack.hpp @@ -1,5 +1,4 @@ -#ifndef STACK_HPP -#define STACK_HPP +#pragma once #include @@ -15,7 +14,7 @@ public: * * @param capacity The capacity of the stack */ - Stack(int capacity); + Stack(unsigned long capacity); /** * Pushes a item onto the stack. @@ -40,4 +39,3 @@ private: #include "stack.tpp" -#endif diff --git a/src/stack.tpp b/src/stack.tpp index 958d6ca..405d493 100644 --- a/src/stack.tpp +++ b/src/stack.tpp @@ -3,7 +3,7 @@ #include template -Stack::Stack(int capacity) +Stack::Stack(unsigned long capacity) { _items.reserve(capacity); } diff --git a/src/utils.cpp b/src/utils.cpp index 30ff4ec..480c31f 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -27,8 +27,8 @@ unsigned int str_to_uint(std::string str) if (waste_pos != str.length()) throw "Not a number"; - if (num > (unsigned long)UINT_MAX) + if (num > UINT_MAX) throw "Out of range"; - return (unsigned int)num; + return static_cast(num); } -- cgit v1.2.3-18-g5258