On Thu, Sep 24, 2015 at 12:04 PM, jmp <jeanmic...@sequans.com> wrote: > I'm not an expert but I think this "return by value thing" is only for C++. > In vintage C, you can only return something that fits within a register.
If that was true at one time, it was before ANSI C. $ cat test.c #include <assert.h> struct foo { int a; long b; float c; double d; }; struct foo get_foo() { struct foo value; value.a = 12; value.b = 92L; value.c = 4.5f; value.d = -21.5; return value; } int main() { struct foo value = get_foo(); assert(value.a == 12); assert(value.b == 92L); assert(value.c == 4.5f); assert(value.d == -21.5); return 0; } $ gcc -Wall -O0 -std=c89 test.c $ ./a.out $ There is a danger however in that it's only a shallow copy. If any struct members are pointers, then the pointer value will be copied, not the thing pointed to. -- https://mail.python.org/mailman/listinfo/python-list