TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: ALL
from: David Breeding 72330,2051
date: 1994-06-25 13:33:43
subject: #Coco/OSK C compilers

#: 20067 S3/Languages
    25-Jun-94  13:33:43
Sb: #Coco/OSK C compilers
Fm: David Breeding 72330,2051
To: ALL

Here's a little "feature" of the MW OSK C compiler I _BELIEVE_ I've stumbled
across.  It could be common knowledge, but I'd never heard of it myself.  Seems
that with a structure, from what I can determine, a block of characters joined
by an int, float, and ???, will have a character added if the total for that
blockof characters is odd.  This won't hurt the program, but would cause
problems in sharing files with systems that don't do this.  I found this by
trying to port a prog from the coco to OSK.  I was looking for int's, but was
surprised in the filesize incongruity with structures containing only floats &
chars.  It seems that the following will result;

  * char a1[x];char c1[y];int b1 : if a1+c1=odd, one byte added, same
  *        if int b1 before the two.
  * char a1[x];int b1;char c1[y] : if EITHER a1 OR c1 = odd, one byte
  *      added, if both odd, 2 bytes added.

  * sizeof() reports correctly the actual size, reflecting any
  * additional bytes added.  If this _IS_ news, and anyone wants to
  * play around with it, here's a little routine for it.

 struct {       /* Play around with the order of the elements...*/
  char a1[24];
  int b1;
  char c1;
 } S1;

 char a2;

 main()
 {
    printf(" Size of S1   : %d\n", sizeof(S1) );
    printf(" Actual Size  : %d\n\n", (int)(&a2)-(int)(&S1) );
    printf(" Totals of els: %d\n",
          sizeof(S1.a1)+sizeof(S1.b1)+sizeof(S1.c1) );
 }


Another difference between the CoCo and the OSK compilers, although
insignificant, I suppose, is in mktemp().  The OSK mktemp checks the directory
for a unique tmpfile name, probably doing an "Open".  It exits with Error #216
in "errno" - Coco doesn't.  I like to end a program with "exit(errno)", which
looks kinda messy.  Guess I'll either have to cleanup after mktemp (and
others???) or do an exit(0)      .


                   -- David Breeding --
                 CompuServe :  72330,2051
                     Delphi :  DBREEDING

         ***  Sent via CoCo-InfoXpress V1.01 ***
                       ^^^^ ^^^^^^^^^^

There is 1 Reply.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.