Propeller C Multiple return
MJF
Posts: 19
Can anyone help with multiple returns from a function in C.
I am looking to pass one piece of data into a function and get two pieces of data returned.
I am looking to pass one piece of data into a function and get two pieces of data returned.
Comments
it would be to integer values a=1234 b=4567.
Don't completely understand , but I will give it a try.
1. Return a pointer which could be a pointer to a struct with multiple values.
2. Take a struct parameter and fill multiple values in that.
3. Take multiple pointer parameters and fill values for them.
4. Variations of 1 through 3.
I haven't used C much lately, but I thought this was something C and Spin had in common.
Since Propeller GCC is just C targeted to the Propeller all of the generic C aspects translate. This is one such case.
This works fine: I wouldn't recommend using this technique to return large structures but it is certainly okay for small ones like in this example.
That would be my suggestion. Anytime I need to pass around multiple related values a structure pops straight to mind. Mike's packing method will work too and is compact but the structure is more clear in my opinion.