bshoshany / thread-pool

BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library
MIT License
2.21k stars 253 forks source link

[TEST] test program failed to compile #154

Closed AlexanderBarnt closed 1 month ago

AlexanderBarnt commented 1 month ago

Tried to compile the test program in the repository -> tests/BS_thread_pool_test.cpp

System information

Log file

Build started at 12:35 PM...
1>------ Build started: Project: C++ Console Project6, Configuration: Debug Win32 ------
1>Main.cpp
1>c:\users\user\desktop\c++ console project6\c++ console project6\main.cpp(1709): warning C4834: discarding return value of function with 'nodiscard' attribute
1>x:\thread-pool-4.1.0\compiled\include\bs_thread_pool.hpp(622): error C2660: 'std::promise<void>::set_value': function does not take 1 arguments
1>c:\program files\microsoft visual studio\2022\community\vc\tools\msvc\14.16.27023\include\future(1601): note: see declaration of 'std::promise<void>::set_value'
1>c:\users\user\desktop\c++ console project6\c++ console project6\main.cpp(480): note: see reference to function template instantiation 'std::future<void> BS::thread_pool::submit_task<const std::function<void (void)>&,void>(F,const BS::priority_t)' being compiled
1>        with
1>        [
1>            F=const std::function<void (void)> &
1>        ]
1>c:\program files\microsoft visual studio\2022\community\vc\tools\msvc\14.16.27023\include\type_traits(616): note: see reference to class template instantiation 'std::basic_string_view<char,std::char_traits<char>>' being compiled
1>c:\program files\microsoft visual studio\2022\community\vc\tools\msvc\14.16.27023\include\xstring(2122): note: see reference to class template instantiation 'std::is_convertible<const _StringViewIsh (&),std::basic_string_view<char,std::char_traits<char>>>' being compiled
1>        with
1>        [
1>            _StringViewIsh=char [2]
1>        ]
1>c:\program files\microsoft visual studio\2022\community\vc\tools\msvc\14.16.27023\include\xstring(2122): note: see reference to variable template 'const bool conjunction_v<std::is_convertible<char const (&)[2],std::basic_string_view<char,std::char_traits<char> > >,std::negation<std::is_convertible<char const (&)[2],char const *> > >' being compiled
1>c:\program files\microsoft visual studio\2022\community\vc\tools\msvc\14.16.27023\include\xstring(3774): note: see reference to alias template instantiation 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Is_string_view_ish<_StringViewIsh>' being compiled
1>        with
1>        [
1>            _StringViewIsh=char [2]
1>        ]
1>x:\thread-pool-4.1.0\compiled\include\bs_thread_pool.hpp(618): error C2661: 'std::promise<R>::set_value': no overloaded function takes 0 arguments
1>        with
1>        [
1>            R=bool
1>        ]
1>c:\users\user\desktop\c++ console project6\c++ console project6\main.cpp(548): note: see reference to function template instantiation 'std::future<bool> BS::thread_pool::submit_task<const std::function<bool (void)>&,bool>(F,const BS::priority_t)' being compiled
1>        with
1>        [
1>            F=const std::function<bool (void)> &
1>        ]
1>c:\users\user\desktop\c++ console project6\c++ console project6\main.cpp(2043): error C3493: 'tries' cannot be implicitly captured because no default capture mode has been specified
1>c:\users\user\desktop\c++ console project6\c++ console project6\main.cpp(2527): note: see reference to function template instantiation 'void check_deadlock<main::<lambda_2dfd3286e33c22ab67303b10817c0f1f>>(const F &&)' being compiled
1>        with
1>        [
1>            F=main::<lambda_2dfd3286e33c22ab67303b10817c0f1f>
1>        ]
1>x:\thread-pool-4.1.0\compiled\include\bs_thread_pool.hpp(148): note: see reference to class template instantiation 'std::optional<BS::thread_pool *>' being compiled
1>Done building project "C++ Console Project6.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 12:35 PM and took 01.928 seconds ==========
bshoshany commented 1 month ago

Hi @AlexanderBarnt and thanks for opening this issue!

  1. Just to be clear, is the file you are compiling, main.cpp, identical to the file BS_thread_pool_test.cpp from this repository? If the code for your main.cpp is different, please post it here.
  2. Please run the PowerShell script BS_thread_pool_test.ps1, which will compile the test program with MSVC compiler flags that I know for certain work. Let me know if that works or not. If not, then the problem is probably in one of the extra compiler flags you are using, so please try removing some of them and seeing if that works.