Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 409786b

Browse files
committed
Eliminate all Windows (VS 2017) build warnings
- use %zu format rather than %lu for printf with size_t types. - explicitly throw away "nodiscard" return value of std::adjacent_find(). - explicitly cast to unsigned type when creating a Taskflow. - (git) ignore Windows/MSVC files and directories.
1 parent 00e4420 commit 409786b

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@ build/
22
example/simple
33
*.swp
44
*.sh
5+
6+
# Windows/MSVC
7+
.vs/
8+
*.exe
9+
*.pdb
10+
*.ilk
11+

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ set(CMAKE_CXX_STANDARD 17)
3838
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3939
set(CMAKE_CXX_EXTENSIONS OFF)
4040
#set(USE_WERROR ON)
41-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2")
41+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
42+
# The warning and optimization flags are already set correctly for the
43+
# configuration; don't override them here
44+
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /O2")
45+
else()
46+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2")
47+
endif()
4248
message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
4349
message(STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER})
4450
message(STATUS "CMAKE_CXX_COMPILER_VERSION: " ${CMAKE_CXX_COMPILER_VERSION})

example/matrix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ matrix_t operator * (const matrix_t& A, const matrix_t& B) {
4949
K = A[0].size();
5050
M = B[0].size();
5151

52-
printf("A[%lux%lu] * B[%lux%lu]\n", N, K, K, M);
52+
printf("A[%zux%zu] * B[%zux%zu]\n", N, K, K, M);
5353

5454
// Initialize the matrix
5555
matrix_t ret(N);

taskflow/taskflow.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ auto BasicFlowBuilder<NodeType>::transform_reduce(
982982
template <typename NodeType>
983983
template <typename L>
984984
void BasicFlowBuilder<NodeType>::_linearize(L& keys) {
985-
std::adjacent_find(
985+
(void) std::adjacent_find(
986986
keys.begin(), keys.end(),
987987
[] (auto& from, auto& to) {
988988
from._node->precede(*(to._node));

unittest/taskflow.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ TEST_CASE("Taskflow.Builder" * doctest::timeout(5)){
1616
size_t num_workers = 4;
1717
size_t num_tasks = 100;
1818

19-
tf::Taskflow tf(num_workers);
19+
tf::Taskflow tf(static_cast<unsigned>(num_workers));
2020
REQUIRE(tf.num_workers() == num_workers);
2121

2222
std::atomic<int> counter {0};
@@ -184,7 +184,7 @@ TEST_CASE("Taskflow.Dispatch" * doctest::timeout(5)) {
184184
size_t num_workers = 4;
185185
size_t num_tasks = 100;
186186

187-
tf::Taskflow tf(num_workers);
187+
tf::Taskflow tf(static_cast<unsigned>(num_workers));
188188
REQUIRE(tf.num_workers() == num_workers);
189189

190190
std::atomic<int> counter {0};
@@ -224,7 +224,7 @@ TEST_CASE("Taskflow.ParallelFor" * doctest::timeout(5)) {
224224
using namespace std::chrono_literals;
225225

226226
const auto mapper = [](size_t num_workers, size_t num_data, bool group){
227-
tf::Taskflow tf(num_workers);
227+
tf::Taskflow tf(static_cast<unsigned>(num_workers));
228228
std::vector<int> vec(num_data, 0);
229229
tf.parallel_for(vec, [] (int& v) { v = 64; }, group ? ::rand() : 0);
230230
for(const auto v : vec) {
@@ -237,7 +237,7 @@ TEST_CASE("Taskflow.ParallelFor" * doctest::timeout(5)) {
237237
};
238238

239239
const auto reducer = [](size_t num_workers, size_t num_data, bool group){
240-
tf::Taskflow tf(num_workers);
240+
tf::Taskflow tf(static_cast<unsigned>(num_workers));
241241
std::vector<int> vec(num_data, 0);
242242
std::atomic<int> sum(0);
243243
tf.parallel_for(vec, [&](auto) { ++sum; }, group ? ::rand() : 0);
@@ -273,7 +273,7 @@ TEST_CASE("Taskflow.ParallelFor" * doctest::timeout(5)) {
273273
TEST_CASE("Taskflow.Reduce" * doctest::timeout(5)) {
274274

275275
const auto plus_test = [](const size_t num_workers, auto &&data){
276-
tf::Taskflow tf(num_workers);
276+
tf::Taskflow tf(static_cast<unsigned>(num_workers));
277277
int result {0};
278278
std::iota(data.begin(), data.end(), 1);
279279
tf.reduce(data.begin(), data.end(), result, std::plus<int>());
@@ -282,7 +282,7 @@ TEST_CASE("Taskflow.Reduce" * doctest::timeout(5)) {
282282
};
283283

284284
const auto multiply_test = [](const size_t num_workers, auto &&data){
285-
tf::Taskflow tf(num_workers);
285+
tf::Taskflow tf(static_cast<unsigned>(num_workers));
286286
std::fill(data.begin(), data.end(), 1.0);
287287
double result {2.0};
288288
tf.reduce(data.begin(), data.end(), result, std::multiplies<double>());
@@ -291,7 +291,7 @@ TEST_CASE("Taskflow.Reduce" * doctest::timeout(5)) {
291291
};
292292

293293
const auto max_test = [](const size_t num_workers, auto &&data){
294-
tf::Taskflow tf(num_workers);
294+
tf::Taskflow tf(static_cast<unsigned>(num_workers));
295295
std::iota(data.begin(), data.end(), 1);
296296
int result {0};
297297
auto lambda = [](const auto& l, const auto& r){return std::max(l, r);};
@@ -301,7 +301,7 @@ TEST_CASE("Taskflow.Reduce" * doctest::timeout(5)) {
301301
};
302302

303303
const auto min_test = [](const size_t num_workers, auto &&data){
304-
tf::Taskflow tf(num_workers);
304+
tf::Taskflow tf(static_cast<unsigned>(num_workers));
305305
std::iota(data.begin(), data.end(), 1);
306306
int result {std::numeric_limits<int>::max()};
307307
auto lambda = [](const auto& l, const auto& r){return std::min(l, r);};

0 commit comments

Comments
 (0)