sizeof int < 32
William E. Davidsen Jr
davidsen at steinmetz.ge.com
Fri Apr 15 02:11:00 AEST 1988
In article <451 at viscous> brianm at sco.COM (Brian Moffet) writes:
| [...]
| I hope you have source code to _all_ your functions. What happens
| if something like printf is expecting an int (16 bit) for a "%d" ?
| You end up putting more on the stack than you intended.
| Putting more on the stack will only give you the right answer if
| your longs are stored least sig. word first. (little endian ?)
As you say, but worse. Unless it's the last argument, using something
too big will mess up the next (or previous) argument. In the application
I was using for an example, the INT hold either four characters or 32
bit flags. I don't ever print it, it's just used for internal data and
passed to procedures expecting and using the matching type.
I agree that anything like this requires careful attention to matching
types if it is to be portable.
--
bill davidsen (wedu at ge-crd.arpa)
{uunet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me
More information about the Comp.lang.c
mailing list