This #ifdef is pretty brutal.  How about sorting the lowest common denominator instead of having to do things twice?