tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] pointers to static functions inside a static table


From: Thomas Preud'homme
Subject: Re: [Tinycc-devel] pointers to static functions inside a static table
Date: Wed, 18 May 2011 22:57:55 +0200
User-agent: KMail/1.13.5 (Linux/2.6.38-2-amd64; KDE/4.4.5; x86_64; ; )

Le vendredi 27 août 2010 12:47:35, Aharon Robbins a écrit :
> Hi. I've reported this before, but here is a small test case:
> 
> $ cat foo.c
> #include <stdio.h>
> 
> static void func();
> 
> int main(int argc, char **argv)
> {
>       static struct s {
>               void (*elem)();
>       } t[] = {
>               { func }        /* tcc requires these braces! */
>       };
> 
>       printf("func is %p, t[0].func is %p\n", func, t[0].elem);
>       return 0;
> }
> 
> static void func()
> {
>       int x = 1;
>       x++;
> }
> 
> $ gcc foo.c ; ./a.out
> func is 0x4004f8, t[0].func is 0x4004f8
> $ tcc foo.c ; ./a.out
> func is 0x8048314, t[0].func is (nil)

A bit late for a correct answer but in fact these parenthesis *are* needed. 
There is one set of parenthesis for the array initialization and then one for 
the structure. Gcc with -Wall gives a warning now (since version 4.6).

[SNIP]

Best regards,

Thomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]