Re: Common Porting Problem

Michal Jaegermann (michal@ellpspace.math.ualberta.ca)
Thu, 28 Nov 1996 16:33:04 -0700 (MST)

>
> I know I'm going to be raked over the coals for asking this, as it's
> probably been rehashed any number of times; here it goes anyway.

If you would have Atari or Amiga you would have run into this problem
a number of years ago. :-)

> Lots of people write code which assumes the same number of bytes in
> pointers & integers;

That is correct. They also assume that longs are four bytes wide and
that "all the world is VAX". It is also correct that such code is simply
broken as written. There is also quite a few programs around written by
people who do not subscribe "it happens to work on my machine, therefore
is right" school of programming.

> when I try to compile such code it complains
> something like
> "warning: cast to pointer from integer of different size"
> And when I try to run , it dumps core, like it's supposed to.

Such "warnings" point, nearly always, to a deadly problem and the code
needs to be fixed.

> My question; is there a compiler switch I can use to make the pointers 4
> bytes or the integers 8, so this stuff will work without major surgery?

As 32-bit version of Linux for AXP vanished in early stages, so I am
afraid that you just need to fix sloppy practices of others. Carefuly
including all required headers and adding prototypes very often goes
a looong way towards working program. gcc has actually a switch which
makes missing prototypes into an error. It is a good idea to use it in
a porting work.

> Or am I doomed to wading through dozens of
> "warning: cast to pointer from integer of different size"
> messages?

Wading through messages does not help. You have to make them
disappear. You should be happy that your compiler helps you to spot
bad code. It is much harder to that from a debugger. :-)

Michal

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com



Feedback | Store | News | Support | Product Errata | About Us | Linux Info | Search | JumpWords
No Frames | Show Frames

Copyright © 1995-1997 Red Hat Software. Legal notices