diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 71fbb256..4d9265af 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -86,8 +86,7 @@ endif() if( CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG ) # We want all warnings, and warnings should be treated as errors - # TODO: -Wextra? - add_definitions( -Wall -Werror ) + add_definitions( -Wall -Wextra -Werror ) endif() add_subdirectory( tests ) diff --git a/cpp/Candidate.cpp b/cpp/Candidate.cpp index 120054a6..28d778a4 100644 --- a/cpp/Candidate.cpp +++ b/cpp/Candidate.cpp @@ -33,7 +33,7 @@ std::string GetWordBoundaryChars( const std::string &text ) { std::string result; - for ( int i = 0; i < text.size(); ++i ) + for ( uint i = 0; i < text.size(); ++i ) { if ( i == 0 || IsUppercase( text[ i ] ) || diff --git a/cpp/LetterHash.cpp b/cpp/LetterHash.cpp index ace88714..7895d0ec 100644 --- a/cpp/LetterHash.cpp +++ b/cpp/LetterHash.cpp @@ -16,6 +16,7 @@ // along with YouCompleteMe. If not, see . #include "LetterHash.h" +#include "standard.h" namespace YouCompleteMe { @@ -45,7 +46,7 @@ LetterHash::LetterHash() { letters_.resize( kNumLetters ); - for ( int i = 0; i < letters_.size(); ++i ) + for ( uint i = 0; i < letters_.size(); ++i ) { letters_[ i ] = NULL; } @@ -54,7 +55,7 @@ LetterHash::LetterHash() LetterHash::~LetterHash() { - for ( int i = 0; i < letters_.size(); ++i ) + for ( uint i = 0; i < letters_.size(); ++i ) { delete letters_[ i ]; } diff --git a/cpp/LetterNode.cpp b/cpp/LetterNode.cpp index 05639d5a..3a2ba6ed 100644 --- a/cpp/LetterNode.cpp +++ b/cpp/LetterNode.cpp @@ -15,8 +15,8 @@ // You should have received a copy of the GNU General Public License // along with YouCompleteMe. If not, see . -#include "standard.h" #include "LetterNode.h" +#include "standard.h" namespace YouCompleteMe @@ -36,7 +36,7 @@ LetterNode::LetterNode( const std::string &text ) letternode_per_text_index_.resize( text.size() ); - for (int i = 0; i < text.size(); ++i) + for ( uint i = 0; i < text.size(); ++i) { char letter = text[ i ]; LetterNode *node = new LetterNode( letter ); @@ -44,7 +44,8 @@ LetterNode::LetterNode( const std::string &text ) letternode_per_text_index_[ i ] = boost::shared_ptr< LetterNode >( node ); } - for ( int i = letternode_per_text_index_.size() - 1; i >= 0; --i ) + for ( int i = static_cast< int >( letternode_per_text_index_.size() ) - 1; + i >= 0; --i ) { LetterNode *node_to_add = letternode_per_text_index_[ i ].get(); diff --git a/cpp/Result.cpp b/cpp/Result.cpp index 84ad4946..1203cc20 100644 --- a/cpp/Result.cpp +++ b/cpp/Result.cpp @@ -16,6 +16,7 @@ // along with YouCompleteMe. If not, see . #include "Result.h" +#include "standard.h" #include "Utils.h" #include @@ -30,8 +31,8 @@ namespace int NumWordBoundaryCharMatches( const std::string &query, const std::string &word_boundary_chars ) { - int i = 0; - int j = 0; + uint i = 0; + uint j = 0; while ( j < query.size() && i < word_boundary_chars.size() ) { if ( toupper( query[ j ] ) == toupper( word_boundary_chars[ i ] ) ) diff --git a/cpp/standard.h b/cpp/standard.h index 03555af5..6948332c 100644 --- a/cpp/standard.h +++ b/cpp/standard.h @@ -20,3 +20,11 @@ // We're most definitely not going to use // it as BOOST_FOREACH. #define foreach BOOST_FOREACH + + +namespace YouCompleteMe +{ + +typedef unsigned int uint; + +} // namespace YouCompleteMe