[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] Strange sizeof construct
From: |
Marc Andre Tanner |
Subject: |
[Tinycc-devel] Strange sizeof construct |
Date: |
Tue, 13 Nov 2007 20:00:11 +0100 |
User-agent: |
Mutt/1.5.17 (2007-11-01) |
Hi,
Could a C guru out there please tell me why the following works? Extra points
if you can explain why it makes sense.
#include <stdio.h>
int main(){
int arr[10];
printf("%d\n",sizeof arr[0]); // ok
printf("%d\n",sizeof(arr[0])); // ok
printf("%d\n",sizeof(arr)[0]); // ok, but why?
return 0;
}
gcc compiles it:
$> gcc -ansi -std=c99 -Wall sizeof.c && ./a.out
4
4
4
$> tcc sizeof.c
sizeof.c:7: pointer expected
Thanks,
Marc
--
Marc Andre Tanner >< http://www.brain-dump.org/ >< GPG key: CF7D56C0
- [Tinycc-devel] Strange sizeof construct,
Marc Andre Tanner <=