Can anybody explain why this code compiles:
typedef struct longlong { unsigned long low; long high; } longlong; typedef longlong Foo; struct FooStr
Reasons for this behavior were described in other answers.
One way to avoid this behavior would be qualifying your return type with const:
const
struct FooStruct { ... const Foo GetBar() {return bar;} };
You cannot assign values to const objects, so the compiler will complain.