brianm@sco.COM (Brian Moffet) (04/12/88)
With regard to the #if sizeof int < 32 #define int long #else #define int long /*?*/ #endif 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 ?) -- Brian Moffet brianm@sco.com {uunet,decvax!microsof}!sco!brianm The opinions expressed are not quite clear and have no relation to my employer. 'Evil Geniuses for a Better Tommorrow!'
davidsen@steinmetz.ge.com (William E. Davidsen Jr) (04/14/88)
In article <451@viscous> brianm@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@ge-crd.arpa) {uunet | philabs | seismo}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me