home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 395 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.5 KB

  1. Path: nntp.teleport.com!sschaem
  2. From: sschaem@teleport.com (Stephan Schaem)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: PPC compilers
  5. Date: 7 Jan 1996 14:16:48 GMT
  6. Organization: Teleport - Portland's Public Access (503) 220-1016
  7. Message-ID: <4cokkg$415@maureen.teleport.com>
  8. References: <john.hendrikx.40ka@grafix.xs4all.nl> <MQAQx*XOe@yaps.rhein.de> <4bqhnf$6g5@sunsystem5.informatik.tu-muenchen.de> <jasonb.820051107@cs.uwa.edu.au> <4c9i2l$h3i@sunsystem5.informatik.tu-muenchen.de> <4ck47h$g07@maureen.teleport.com> <19960106.4EE928.CF59@sisyphus.demon.co.uk>
  9. NNTP-Posting-Host: julie.teleport.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Dave.Sparks@sisyphus.demon.co.uk wrote:
  13. : >>>>> "SS" == Stephan Schaem <sschaem@teleport.com> writes:
  14.  
  15. :   SS>  I cant see how people can write code without knowing what data or
  16. :   SS> type they manipulate...
  17.  
  18. : Real-world programmers do it all the time.  If you ever want to
  19.  
  20.  So you do math operation without knowing that your destination need to 
  21.  be a float or a 2 byte int? 
  22.  
  23. : join us, you'll have to learn to do it too.  One of many examples
  24.  
  25.  Real world = commercial? I'm deep in it, thanks
  26.  
  27. : is the ANSI C definition of the 'clock' function: the value
  28. : returned is of type 'clock_t', which is defined in a
  29. : system-dependent header file.  SAS/C defines 'clock_t' to be an
  30. : unsigned 32-bit value, but other implementations can (and do)
  31. : define it to be signed or even 64-bit floating-point.  Since the C
  32. : arithmetic operations (add, subtract, multiply, divide) are
  33. : overloaded (can be used on values of different types) the
  34. : programmer doesn't need to know what 'clock_t' is defined to be.
  35. : It isn't difficult to write ANSI C code which will compile and run
  36. : on different architectures: what is difficult is to convert C
  37. : which was written for one specific architecture, with no thought
  38. : given to portability.
  39.  
  40.  ANSI for good reason decided on a minimal size of all its basic type.
  41.  This to help you the program choose the right type for your need.
  42.  
  43.  The only way you dont care is if you typedef all the ANSI type.
  44.  
  45.  So you created a structure to hold clock value with ulong? now recompile
  46.  this on the system using a clock size of 64bit... where did the upper
  47.  32bit goes... you know have code that is broken.
  48.  
  49.  ex of something that wont break with a recompile:
  50.  
  51.  typedef short point2d
  52.  
  53.  struct    RECTANGLE {
  54.     point2d    x1;
  55.     point2d    y1;
  56.     point2d    x2;
  57.     point2d    y2;
  58.  } rectangle, *rectangle;
  59.  
  60.  then you declare you variable using rectangle, or point2d
  61.  
  62.  Then if later you find out in your design you need to use long (Or
  63.  create another set of include for another platform), you
  64.  can just chnage point2d... I rarely see that done... anyway
  65.  
  66.  It could be done in a macro assembler by 'tydefing' instruction size.
  67.  
  68.  typedef .w .point
  69.  
  70.  move.point    (global_x1,a4),(rectangle+x1,a1)
  71.  
  72.  problem here... not all inst support all size :)
  73.  
  74.  The overall point here is. in C you need to know the type of x1 at
  75.  declararion time, in asm at usage time. I guess in C you declare
  76.  and forget? But this is not cool if you forget you are working with
  77.  2 byte ints...
  78.  
  79.  about loop counter size... should I use ulong and forget about it, 
  80.  or use ushort to be sure of optimal speed on my target CPU and remember
  81.  my declaration type in case I want to use it for a loop count bigger then
  82.  65535?. (this result in a sub/bcc  vs  dbcc encoding on 680x0... )
  83.  
  84.  
  85. : Incidentally, your References: header was broken (truncated in the
  86. : middle of a reference).  You need to write yourself a new newsreader.
  87.  
  88.  I'm using tin :( 
  89.  
  90.  Stephan
  91.