ensuring ANSI C compatibility by using ifdefs where appropriate