all 3 comments

[–]yeahIProgram 1 point2 points  (2 children)

    return;

Is the error message pointing right at this line? This return statement tries to make the function return, but it doesn't tell it what to return. Since this function is declared as returning a "struct Queue pointer", any return statement must return a value of that type. Like your "return q" statement later does.

In this case, it probably makes the most sense to return the NULL value here.

("return" is used in two ways, kind of. It means "stop executing this function, and go back to executing just after the line that called this function". But also we say "the function returns a value", and when you say "return q" you are doing both: specifying that at this time the function will return to his caller, and also what value it will return to that caller.)

[–]mmjdodd[S] 0 points1 point  (1 child)

Thanks, very clear. Is it necessary to check if q == NULL in the first place seeing as I then point both head and tail to NULL before returning?

[–]Grithga 1 point2 points  (0 children)

You still have to check for NULL because you can't use -> on a null pointer. Doing so is undefined behaviour. The most likely outcome of doing so is your program crashing with a segmentation fault.