At 12:04 PM -0700 2005/5/7, Jacob Nelson wrote:
GCC knows how big an array is:

jake$ cat > arrsizetest.c
#include <stdio.h>

int main()
{
        int a[50];
        printf("sizeof a == %d\n",sizeof(a));
        return 0;
}
jake$ gcc arrsizetest.c
jake$ ./a.out
sizeof a == 200

jacob


gcc knows the size of an array variable only in the scope of its definition:

#include <stdio.h>

void f( int x[] )
{
        printf("f:    sizeof a == %d\n",sizeof(x));
}

int main()
{
        int a[50];
        printf("main: sizeof a == %d\n",sizeof(a));
        f( a );
        return 0;
}

ham% gcc arrsize.c
ham% a.out
main: sizeof a == 200
f:    sizeof a == 4

Cheers,

--Ham

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to