Skip to content

Commit

Permalink
Fix strict warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLoach committed Mar 13, 2024
1 parent e8ad0e5 commit 114b5de
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PUBLIC
)

set_target_properties(c-vector-example PROPERTIES C_STANDARD 90)
target_compile_options(c-vector-example PUBLIC -Wall -Wextra)
target_compile_options(c-vector-example PUBLIC -Wall -Werror -Wextra)

# ----------------------------

Expand All @@ -35,7 +35,7 @@ add_executable(test-c-vector

add_test(NAME test-c-vector COMMAND test-c-vector)
set_target_properties(test-c-vector PROPERTIES C_STANDARD 90)
target_compile_options(test-c-vector PUBLIC -Wall -Wextra)
target_compile_options(test-c-vector PUBLIC -Wall -Werror -Wextra)

add_test(test_build
"${CMAKE_COMMAND}"
Expand Down Expand Up @@ -69,7 +69,7 @@ add_executable(unit-tests

add_test(NAME unit-tests COMMAND $<TARGET_FILE:unit-tests>)
set_target_properties(unit-tests PROPERTIES C_STANDARD 90)
target_compile_options(unit-tests PUBLIC -Wall -Wextra)
target_compile_options(unit-tests PUBLIC -Wall -Werror -Wextra)

add_test(unit_test_build
"${CMAKE_COMMAND}"
Expand Down
2 changes: 1 addition & 1 deletion cvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ typedef struct cvector_metadata_t {
* @return the element at the specified position in the vector.
*/
#define cvector_at(vec, n) \
((vec) ? ((n < 0 || n >= cvector_size(vec)) ? NULL : &(vec)[n]) : NULL)
((vec) ? (((int)(n) < 0 || (size_t)(n) >= cvector_size(vec)) ? NULL : &(vec)[n]) : NULL) \

/**
* @brief cvector_front - returns a reference to the first element in the vector. Unlike member cvector_begin, which returns an iterator to this same element, this function returns a direct reference.
Expand Down
2 changes: 1 addition & 1 deletion unit-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ UTEST(test, vector_at) {

if (v) {
int i = 0;
for (; i < cvector_size(v); i++) {
for (; i < (int)cvector_size(v); i++) {
ASSERT_TRUE(*cvector_at(v, i) == i);
}
}
Expand Down

0 comments on commit 114b5de

Please sign in to comment.