F
Fei Liu
Hello, this is a follow-up question I had about typedef usage in Gianni
Mariani's thread:
int foo(int A, int * pA){ return 0; }
int main(){
typedef int * pi;
typedef int ii;
int a = sizeof(foo(ii(), pi()));
}
I understand the function foo never actually gets called, but what
causes the compiler to ignore this usage (without any actual storage
unit or variable declaration)? Normally one cannot call a function like
this. Also I didn't find any reference that sizeof can be used to take
the size of a function return type during compile time. I know what this
code is doing and it makes sense to me. But it seems like I can't find
any reference that says this is correct and proper use of C++ syntax.
This is the first time this kind of sizeof and typedef usage get my
attention, where I can read/learn about this typedef trick?
Thanks,
Fei
Mariani's thread:
int foo(int A, int * pA){ return 0; }
int main(){
typedef int * pi;
typedef int ii;
int a = sizeof(foo(ii(), pi()));
}
I understand the function foo never actually gets called, but what
causes the compiler to ignore this usage (without any actual storage
unit or variable declaration)? Normally one cannot call a function like
this. Also I didn't find any reference that sizeof can be used to take
the size of a function return type during compile time. I know what this
code is doing and it makes sense to me. But it seems like I can't find
any reference that says this is correct and proper use of C++ syntax.
This is the first time this kind of sizeof and typedef usage get my
attention, where I can read/learn about this typedef trick?
Thanks,
Fei