cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/22/12:30:28

Newsgroups: comp.os.msdos.djgpp
Subject: Re: %d
From: you AT somehost DOT somedomain (Herman Schoenfeld)
Organization: Your Organization
References: <Pine DOT SUN DOT 3 DOT 91 DOT 970922091803 DOT 11436B-100000 AT is>
MIME-Version: 1.0
NNTP-Posting-Host: 139.134.41.45
Message-ID: <34268326.0@139.134.5.33>
Date: 22 Sep 97 14:39:34 GMT
Lines: 29
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>Relax, you will *never* get a crash with `printf' because of this.
>
>In fact, altough ANSI C permits it, I'd advise against declaring *any* 
>functions (even with constant argument lists) with shorts or floats as 
>one of the arguments; I suggest to always use ints and doubles instead.

Why not shorts?

ie, if you wanted a memcpy routine word writes then 

void memcpy(char *to, char *from, int len)
{
  len /=sizeof(short);
  char *t = (short *) to;
  char *f = (short *) from; 
  while(len--) {
   *t++=*f++
   };
};


whereas if you knew your buffers would %4

void memcpy(char *to, char *from, int len)
{
  len /=sizeof(int);
  char *t = (int *)to;
  char *f = (int *)from;
  while (len--) {
   *t++=*f++;
  };
};




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019