On Sunday, May 5, 2019 at 1:09:47 AM UTC+8, Jan Mercl wrote:
>
> On Sat, May 4, 2019 at 6:53 PM T L <tapi...@gmail.com <javascript:>> 
> wrote: 
>
> > BTW, the type bar is defined as 
> > 
> > typedef struct bar bar; 
>
> If struct bar is not yet defined at that point then it's an incomplete 
> type. So is bar. Not sure if calling an incomplete type 'defined' 
> makes sense. 
>
> However, this should be IMO ok 
>
>         typedef struct bar bar; // bar is an incomplete type 
>
>         struct bar { int foo; }; // bar is now a complete type 
>
>         bar [2]x; // This declaration of x is now ok. 
>

Thanks for the explanations.

Long time not using c/c++. It looks it is a deference between c and c++.
The following program compiles ok for g++ and clang++, but not gcc and 
clang.

typedef struct bar bar;

int foo(bar bars[]) {
    return 0;
}

int main() {
    int x = 1;
    bar* y = (bar*)&x;
    return foo(y);
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to