Content deleted Content added
→Call by reference or call by value?: new section |
→Call by reference or call by value?: comment |
||
Line 21:
In C, when calling a subroutine or receiving a return value, is a struct passed/returned by value or by reference? Does the [http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf ISO/IEC C standard] discuss this topic explicitly? Thanks, --[[User:Abdull|Abdull]] ([[User talk:Abdull|talk]]) 09:18, 2 May 2010 (UTC)
:I haven't looked at the standard you mention, but it has always been part of C that a struct is passed and returned by value. If a struct contains data occupying 1000 bytes, the compiler pushes 1000 bytes onto the stack. C programmers often pass a pointer to a struct, which is what a "pass by reference" language would do. I suppose this could be mentioned somewhere (it is implied at [[C (programming language)#Characteristics]]), but it's probably excessive detail for an article. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:03, 3 May 2010 (UTC)
|