Port 10.10 fixes to gcc46 and gcc47.

The patch for gcc48 applies to gcc46 and gcc47, allowing those to be
built on Mac OS X 10.10. Fixes #515, fixes #548.

(See commit 843d2baf2c25e3bebd6b909c7a023a14137b6d72).