C - control reaches the end of a non-void function

I am writing a program for streaming, and the pthread_create method requires the void * function.

I get the warning “control to the end of the non-invalid function”, and I understand why (because I do not have an official return statement) - is my question really what should I return in this case?

Is it possible to just return NULL? I don’t think that my return value will affect anything else in my program, but I’m just wondering what the standard is to avoid this warning when programming with multithreaded programs.

+5
source share
2 answers

Returning NULL is fine, and this is the normal way. Nothing will use the return value unless you have written code to use it. NULL is a valid value for void * , and if you don't care what that value is, then the only thing that matters is that it really is.

+5
source

try something like this:

 #include <pthread.h> void* you_func( void* param ) { // do stuff here ... // and terminates as follows: pthread_exit( NULL ); } 

Hope this helps you.

+1
source

Source: https://habr.com/ru/post/1203519/


All Articles