1

I'm new to C and recently when i'm learning zeromq (work related) I'm kinda confused with the static void *:

...
static void *
worker_task(void *args)
{
...

What is the exact the meaning of that line? I tried looking for answer, I thought that it was a pointer but It is kinda odd, given that pointer usually have a variable name after the '*'.

Thank you very much, I hope It's not rude of me for asking this seemingly "novice" question. :)

raharaha
  • 107
  • 1
  • 11
  • 2
    Note the separation on two different lines has no effect. The example is the same as `static void *worker_task(void *args)` on one line. – owacoder Oct 18 '16 at 01:53
  • oh i thought that it was a two separate line! thank you very much for your answer. – raharaha Oct 18 '16 at 02:17

1 Answers1

2

The function worker_task returns a void *.

The static keyword in front of the function definition means that the function is only viewable inside of the current compilation unit, i.e. a given object file, typically built from one source file with several include files. The function is not visible from other object files that may be linked with with one containing this function.

dbush
  • 205,898
  • 23
  • 218
  • 273
  • I think that answer is a little sloppy. If the function appeared in a header file, then it would be "visible" to anyone including that header file, but it would be a separate entity in every translation unit. The point is that `static` makes the function name have *internal linkage*. – Kerrek SB Oct 18 '16 at 08:52