RE: [GD-General] Some portability questions
Brought to you by:
vexxed72
From: Brian H. <bri...@py...> - 2002-11-08 19:29:07
|
> Nothing wrong with answer (1) - it's the way I've done it in > the past. Zealots would advocate you use a union rather than > a cast, but we've had that particular religious war. Since there's no downside to using a union, I use unions now for that type of thing. I've actually found some architectures where casting definitely is bad. For example, this won't be valid: char *x; char *y = x + 5; int i; i = ( int ) x; i += 5; x = (char*)i; if ( x != y ) printf( "Error" ); //this gets hit Even though int and void * are the same sizes, the pointer arithmetic is handled specially because of offset bits in the upper bits of a pointer. However, not many people use UNICOS on Cray systems, so that's not a real big concern =) In fact, the Cray is easily the most disastrous system I've had to try to get things working on in terms of portability. Don't ask. So many things wrong with it I don't even know where to start.... > I thought the early Alphas were even worse - they didn't have > bytes. So string handling all had to be emulated with shifts > and masks and nastiness like that. They didn't have native bytes, so the compiler was responsible for doing the appropriate thing behind your back. The bad part was that the operation wasn't guaranteed to be atomic, which could cause problems if you were doing multithreaded kernel hacking. The 21164 and later added native byte manipulation I think. Brian |