title: Trying to understand syntax quirk around dlsym
body: <p>I've been trying to pick up some osx programming knowledge to complement my win32 programming experience. I figured out that the rough equivalent of GetProcAddress is dlsym. Then I ran into some unexpected hurdles.</p>
  
  <p>I got my code working after a blur of checking old forum posts and trying things, but it did not match my expectations nor did it match what I saw in Apple's own documentation. I'm hoping someone on here can help me understand why.</p>
  
  <p><a href="https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryUsageGuidelines.html" rel="nofollow noreferrer">Apple documentation I was referring to</a></p>
  
  <p>The documentation provides an example that looks like this:</p>
  
  <pre><code>Person_creator* NewPerson = (Person_creator*)dlsym(lib_handle, "NewPerson");
  </code></pre>
  
  <p>And I got my code working by doing this:</p>
  
  <pre><code>void (*printSome)() = (void(*)())dlsym(handle, "printSomething");
  </code></pre>
  
  <p>Where I would have thought my code should have done this:</p>
  
  <pre><code>void* printSome = (void*)dlsym(handle, "printSomething");
  </code></pre>
  
  <p>However, when I do that and try to call printSome(), I get this error message:</p>
  
  <pre><code>Called object type 'void*' is not a function or function pointer
  </code></pre>
  
  <p>I had a silly thought that it might be something unique to a void function pointer (even though nothing in my experience suggested it would be, I was just grasping trying to understand).</p>
  
  <p>So, what gives? What is the extra syntax doing? Why does this appear nowhere in the official documentation?</p>