home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19513 < prev    next >
Encoding:
Internet Message Format  |  1993-01-10  |  1.4 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!newsserver.jvnc.net!rutgers!mcdhup!src4src!wozzle!alane
  2. From: alane@wozzle.linet.org (J. Alan Eldridge)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Problem with Turbo-C: calculating with pointers
  5. Message-ID: <qN76wB6w165w@wozzle.linet.org>
  6. Date: 10 Jan 93 16:36:37 GMT
  7. References: <1993Jan7.112219.578@reks.uia.ac.be>
  8. Organization: Disorganization
  9. Lines: 34
  10.  
  11. derijkp@reks.uia.ac.be (Peter De Rijk) writes:
  12.  
  13. > I am porting a program (working on different platforms such as VAX and DEC) t
  14. > the PC. I am using Turbo C++ v.3.0. I compile using the huge memory model.
  15. > I seem to have tracked down the problem (well, one of the problems.) I don't
  16. > know what to do about it though. Here's a little program to illustrate the
  17. > problem:
  18. > #include <alloc.h>
  19. > main()
  20. > {
  21. > char *pointer,*begin,*end;
  22. > long size;
  23. > size=71800;
  24. > pointer=(char *)farmalloc(size*sizeof(char));
  25. > begin=pointer;
  26. > end=pointer+size;
  27. > printf("%p %p %ld",begin, end, end - begin);
  28. > }
  29. > I would expect end - begin to return 71800. However it seems to return 6264.
  30. > This is exactly 64K less.
  31.  
  32. You have to explicitly declare huge pointers, even in huge model. Make
  33. your var definitions:
  34.  
  35. char huge *pointer, huge *begin, huge *end;
  36.  
  37. This should clear things up for you. BTW It's in the manual... somewhere...
  38.  
  39. alane@wozzle.linet.org (J. Alan Eldridge)
  40. Fido: The University of Walamaloo 1:272/38.473
  41.