Use scandir's POSIX std type signature by default

Older versions of OS X use a definition for the 3rd and 4th
parameters to scandir that differs from the POSIX standard.

Use compiler macros to check the POSIX version and switch between
possible implementations.