Next: Using #ifdef to Up: Conditional selection of Previous: Conditional selection of

Using #ifdef for Different Computer Types

Conditional selection is rarely performed using #defined values. A simple application using machine dependent values is illustrated below.


#include <stdio.h>

main()
{
#ifdef vax
      printf("This is a VAX\n");
#endif
#ifdef sun
      printf("This is a SUN\n");
#endif
}

sun is defined automatically on SUN computers. vax is defined automatically on VAX computers.


craa27@strath.ac.uk
Tue Jan 17 11:40:37 GMT 1995