+ 2

Hi guys. I have troubles with RETURN VALUE from THREAD function

0 My program must to search a file by name from some directory and search it through the threads! Here I created TEMP folder for testing this search,included some diffrent files and here searching for example ".cpp" file.But the problem is not here. The compiler says "must return a value from ThreadSearch", and I've tried many return statements ,but all of it is not suitable,All that i found on internet cannot fix this error,and nobody has an error like in my code,I reckon this is a bug and in the void function it shoud be normal "return;" ,but it does not work and help, in other cases I got errors like "unresolved symbol",maybe somebody can help me with this! here's my code! https://code.sololearn.com/cE0mifJ85f4J/#cpp

14th Mar 2022, 1:15 PM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar
6 Answers
+ 1
I cannot change void* tp void,it has to be like this for that function, i do not wanna return something but I have to,this compiler wants, I've just done this ,I returned nullptr ,but I got another error now Error LNK2019 unresolved external symbol __imp__pthread_join referenced in function _main Error LNK2019 unresolved external symbol __imp__pthread_create referenced in function _main T
14th Mar 2022, 2:02 PM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar
+ 1
I think it works. Error may be any other.. Not sure, cannot debug here. Anything, you return pointer from void*, just type cast to destination type in calling statement. Hope it helps..
14th Mar 2022, 2:10 PM
Jayakrishna šŸ‡®šŸ‡³
+ 1
thanks for advice , Iā€™ll try
14th Mar 2022, 2:12 PM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar
0
The code don't work here... try return 0; instead of return; //it works.. but you can use return as void just instead of void* without returning any value. What you want to return from that function..?
14th Mar 2022, 1:51 PM
Jayakrishna šŸ‡®šŸ‡³
0
What about return 0; ?.
14th Mar 2022, 2:07 PM
Jayakrishna šŸ‡®šŸ‡³
0
it does not match
14th Mar 2022, 2:07 PM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar