Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMakefile: Use -Wpedantic, -Werror and -Wextra for compilation in gcc. Fixed warnings #292

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(argparse
)

option(ARGPARSE_INSTALL "Include an install target" ON)
option(ARGPARSE_BUILD_TESTS "Build tests" OFF)
option(ARGPARSE_BUILD_TESTS "Build tests" ON)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
Expand Down
4 changes: 2 additions & 2 deletions include/argparse/argparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ class Argument {
// align multiline help message
auto stream_width = stream.width();
auto name_padding = std::string(name_stream.str().size(), ' ');
auto pos = 0;
auto prev = 0;
auto pos = std::string::size_type{};
auto prev = std::string::size_type{};
auto first_line = true;
auto hspace = " "; // minimal space between name and help message
stream << name_stream.str();
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if(MSVC)
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Update if necessary
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic -Wsign-conversion -Wshadow -Wconversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wpedantic -Wsign-conversion -Wshadow -Wconversion -Werror -Wextra")
endif()

if(NOT CMAKE_BUILD_TYPE)
Expand Down
4 changes: 2 additions & 2 deletions test/test_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ R"(#Lorem ipsum dolor sit amet, consectetur adipiscing elit.
stream << program;
std::istringstream iss(stream.str());

int help_message_start = -1;
auto help_message_start = std::string::npos;
std::string line;
while (std::getline(iss, line)) {
// Find the position of '#', which indicates the start of the help message line
Expand All @@ -114,7 +114,7 @@ R"(#Lorem ipsum dolor sit amet, consectetur adipiscing elit.
continue;
}

if (help_message_start == -1) {
if (help_message_start == std::string::npos) {
help_message_start = pos;
} else {
REQUIRE(pos == help_message_start);
Expand Down
Loading