[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] Today's bug...
From: |
Rob Landley |
Subject: |
[Tinycc-devel] Today's bug... |
Date: |
Thu, 6 Sep 2007 05:42:35 -0500 |
User-agent: |
KMail/1.9.6 |
#include <stdio.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
struct stat stat;
stat.st_dev = 42;
printf("%ld\n", stat.st_dev);
return 0;
}
Works find with gcc, with tcc it goes:
test.c:8: cannot cast 'int' to 'struct <anonymous>'
Yeah, slightly dodgy, but bear with me.
The _reason_ is that the glibc's /usr/include/bits/types.h has:
> /* quad_t is also 64 bits. */
> #if __WORDSIZE == 64
> typedef long int __quad_t;
> typedef unsigned long int __u_quad_t;
> #elif defined __GLIBC_HAVE_LONG_LONG
> __extension__ typedef long long int __quad_t;
> __extension__ typedef unsigned long long int __u_quad_t;
> #else
> typedef struct
> {
> long __val[2];
> } __quad_t;
And since __GLIBC_HAVE_LONG_LONG isn't defined, it falls through to the struct
definition. That definition comes from /usr/include/features.h, and to make
a long story short we get it by #defining __STDC_VERSION__ 199901L
Since we _do_ support c99, this shouldn't break anything. I think...
Rob
--
"One of my most productive days was throwing away 1000 lines of code."
- Ken Thompson.