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.


  Go to Using #ifdef     Go to Index               Go to #ifdef to remove statements