Merge pull request #512 from kvanberendonck/master

Fix compiler warnings and OSX build failure.

My only reservation is that I prefer the ifs be in the macro to save lines in the actual function bodies, and to be preprocessed away regardless of optimization. As of now, that isn't a big concern, so I'm merging this.