The following piece of C code compiles under gcc 4.7, on a Debian (run with gcc -c filename.c
)
typedef int array_type[3];
int a[] = {1,2,3};
int* asd1(void){
return a;
}
array_type* asd2(void){
return &a;
}
Instead of using the typedef
I want to use the actual type. However, if I replace array_type*
with something like int*[3]
it doesn't compile.
What should I replace array_type*
with to make it semantically the same as above and compile correctly?
int (*asd2(void))[3]{
return &a;
}
see cdecl
Try this:
int (*asd2(void))[3]{
return &a;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.