Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Oct 2007 21:56:50 -0400
From:      "Aryeh M. Friedman" <aryeh.friedman@gmail.com>
To:        RW <fbsd06@mlists.homeunix.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: forcing compilation/run time linking of lib32 on amd64
Message-ID:  <471FF7E2.3010004@gmail.com>
In-Reply-To: <20071025022632.72fd6283@gumby.homeunix.com.>
References:  <471FAFD4.5090500@gmail.com> <20071025022632.72fd6283@gumby.homeunix.com.>

next in thread | previous in thread | raw e-mail | index | archive | help
RW wrote:
> On Wed, 24 Oct 2007 16:49:24 -0400
> "Aryeh M. Friedman" <aryeh.friedman@gmail.com> 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 <stdio.h>

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?471FF7E2.3010004>