/* nag_implementation_details (a00aac) Example Program.
 *
 * Copyright 2017 Numerical Algorithms Group.
 *
 * Mark 26.1, 2017.
 */

#include <nag.h>
#include <stdio.h>
#include <string.h>
#include <nag_stdlib.h>
#include <naga00.h>

int main(void)
{
  Integer exit_status = 0;
  unsigned int sizeofpointer = sizeof(void *);
  unsigned int sizeofInteger = sizeof(Integer);
  unsigned int sp, si;

  /* Get the expected sizes of pointers and integers (in bytes) */
  a00aay(&sp, &si);

  printf("nag_implementation_details (a00aac) Example Program Results\n\n");

  /* Check that the pointer and integer sizes are as expected, and
     issue a warning if not */
  if (sp != sizeofpointer || si != sizeofInteger) {
    printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
           "~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
    if (sp != sizeofpointer)
      printf(" Incorrect value of sizeof(void *)\n"
             "  expected %u, returned %u.\n\n", sp, sizeofpointer);
    if (si != sizeofInteger)
      printf(" Incorrect value of sizeof(Integer)\n"
             "  expected %u, returned %u.\n\n", si, sizeofInteger);
    printf(" The NAG C Library header files are "
           "incompatible with the NAG Library.\n\n");
    printf(" Please check the location of your "
           "NAG C Library include files.\n\n");
    printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
           "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
    exit_status = 1;
  }

  nag_implementation_details();

  return exit_status;
}