Liste des Groupes | Revenir à co vms |
On 8/21/24 19:13, Arne Vajhøj wrote:My assumption would be that the struct was malloc'ed inOn 8/21/2024 8:26 AM, chrisq wrote:Problem is that of you return a pointer, that suggests that theOn 8/21/24 02:25, Lawrence D'Oliveiro wrote:>On Tue, 20 Aug 2024 09:47:36 -0400, Arne Vajhøj wrote:>Few languages support multiple return values.>
Even in C and Fortran, a function can return a struct.
Better to declare the struct externally, then pass a pointer
to it. Much tidier.
In C one should definitely return a pointer to struct and not
struct has been declared static inside the called function. That
would be a fail for reentant code that might be called from
elsewhere, say, from an interrupt handler, or another thread.
The struct would typically be on the stack or heap, and would
disappear on return from the call, making the return value
invalid. Ideally, in a multitasking os, all code should be
designed to be fully reentrant, to make it safe in all
situations.
Les messages affichés proviennent d'usenet.