Re: forcing compilation/run time linking of lib32 on amd64

2007-10-24 Thread Joshua Isom


On Oct 24, 2007, at 8:56 PM, Aryeh M. Friedman wrote:


RW wrote:

On Wed, 24 Oct 2007 16:49:24 -0400
"Aryeh M. Friedman" <[EMAIL PROTECTED]> wrote:



I am writing some demo code (for teaching C) ... showing that
int's are always word length



s/always/typically/

C has been around for a long time and there is always a 
counter-example

to any sweeping generalisation that isn't backed-up by a standards
document.


BTW I was slightly wrong it is longs not int's that change depending on
word size:

Script started on Wed Oct 24 19:51:44 2007



Just remember this, char <= short <= int <= long.  Anything else can be 
anything.  Saying that an int is always four bytes is like saying an 
int is the same size as a pointer, both of which are assumptions that 
are often taken but are very wrong.  A lot of what decides the sizes of 
ints is more compiler implementer than anything else.  Depending on 
your system, you'd want your 36 bit ints instead of being limited to 
only 32.


But if you don't care about portability, then an int is always 32 bits 
and it's always in little endian order.


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: forcing compilation/run time linking of lib32 on amd64

2007-10-24 Thread RW
On Wed, 24 Oct 2007 21:56:50 -0400
"Aryeh M. Friedman" <[EMAIL PROTECTED]> wrote:

> RW wrote:
> > On Wed, 24 Oct 2007 16:49:24 -0400
> > "Aryeh M. Friedman" <[EMAIL PROTECTED]> wrote:
> >
> >   
> >> I am writing some demo code (for teaching C) ... showing that
> >> int's are always word length
> >> 
> >
> > s/always/typically/
> >
> > C has been around for a long time and there is always a
> > counter-example to any sweeping generalisation that isn't backed-up
> > by a standards document. 
> 
> BTW I was slightly wrong it is longs not int's that change depending
> on word size:

What's variable is defined by the standard, not by the  differences
between particular implementations. 
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: forcing compilation/run time linking of lib32 on amd64

2007-10-24 Thread Aryeh M. Friedman
RW wrote:
> On Wed, 24 Oct 2007 16:49:24 -0400
> "Aryeh M. Friedman" <[EMAIL PROTECTED]> wrote:
>
>   
>> I am writing some demo code (for teaching C) ... showing that
>> int's are always word length
>> 
>
> s/always/typically/
>
> C has been around for a long time and there is always a counter-example
> to any sweeping generalisation that isn't backed-up by a standards
> document. 

BTW I was slightly wrong it is longs not int's that change depending on
word size:

Script started on Wed Oct 24 19:51:44 2007

> cat sizes.c
#include 

main()
{
printf("int:\t\t%d\n",sizeof(int));
printf("short:\t\t%d\n",sizeof(short));
printf("long:\t\t%d\n",sizeof(long));
printf("long long:\t%d\n",sizeof(long long));
printf("float:\t\t%d\n",sizeof(float));
printf("double:\t\t%d\n",sizeof(double));
printf("char:\t\t%d\n",sizeof(char));
printf("ptr:\t\t%d\n",sizeof(void *));
}

> gcc sizes.c

> ./a.out
int:4
short:2
long:8
long long:8
float:4
double:8
char:1
ptr:8

> gcc -m32 -B/usr/lib32 -L/usr/lib32 sizes.c  # See "forcing
compilor/run time linking of lib32 on amd54" in freebsd-questions

> ./a.out
int:4
short:2
long:4
long long:8
float:4
double:8
char:1
ptr:4

Script done on Wed Oct 24 19:52:08 2007
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: forcing compilation/run time linking of lib32 on amd64

2007-10-24 Thread RW
On Wed, 24 Oct 2007 16:49:24 -0400
"Aryeh M. Friedman" <[EMAIL PROTECTED]> wrote:

> I am writing some demo code (for teaching C) ... showing that
> int's are always word length

s/always/typically/

C has been around for a long time and there is always a counter-example
to any sweeping generalisation that isn't backed-up by a standards
document. 
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: forcing compilation/run time linking of lib32 on amd64

2007-10-24 Thread Josh Carroll
> I am writing some demo code (for teaching C) and need to have the same
> program run on a 32 bit machine and a 64 bit machine (showing that int's
> are always word length)... I have 8-current amd64 how do I force it to
> compile with 32 bit words?

Add the following to your gcc command line:

-m32 -B/usr/lib32 -L/usr/lib32

Regards,
Josh
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"