getsize.c 609 B

123456789101112131415161718192021222324252627
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* find out if a pointer-sized integer, preferably unsigned,
  7. must be declared as an unsigned int or a long
  8. */
  9. #include <stdio.h>
  10. main()
  11. {
  12. puts("#ifndef size_type");
  13. if (sizeof(unsigned int) == sizeof(char *)) {
  14. puts("#define size_type unsigned int");
  15. }
  16. else if (sizeof(long) == sizeof(char *)) {
  17. puts("#define size_type long");
  18. }
  19. else {
  20. fputs("funny pointer size\n", stderr);
  21. exit(1);
  22. }
  23. puts("#endif");
  24. exit(0);
  25. }