bupticybee / TexasSolver

🚀 A very efficient Texas Holdem GTO solver :spades::hearts::clubs::diamonds:
https://bupticybee.github.io/texassolver_page
GNU Affero General Public License v3.0
1.65k stars 295 forks source link

Warnings due to comparison of integer expressions of different signedness in for loops #185

Closed ruimaciel closed 8 months ago

ruimaciel commented 8 months ago

Building the project on Linux currently results in around 480 warnings, and around a quarter of them are caused by for loops comparing signed ints with unsigned std::vector<T>::size_type, such as the warning shown below.

/home/rui/develop/TexasSolver/src/Card.cpp:59: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
../../../src/Card.cpp: In static member function ‘static uint64_t Card::boardCards2long(std::vector<std::__cxx11::basic_string<char> >)’:
../../../src/Card.cpp:59:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   59 |     for(int i = 0;i < cards.size();i++){
      |                   ~~^~~~~~~~~~~~~~

The goal of this issue is to lower the warning count by updating these for loops to use unsigned ints for its indexes.