Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Returning a pair of items from a function

Tags:

c

assembly

I know all the normal ways of doing this, what I'm looking for is an article I read a long long time ago that showed how to write some crazy helper functions using inline assembly and __naked functions to return a pair of items.

I've tried googling for it endlessly, but to no avail, I'm hoping someone else knows the article I'm talking about and has a link to it.

like image 481
ReaperUnreal Avatar asked Dec 29 '22 06:12

ReaperUnreal


1 Answers

No assembly necessary

struct PairOfItems {int item1;double item2;};
struct PairOfItems crazyhelperfunction(void){
    struct PairOfItems x = {42, -0.42};
    return x;
}

I don't know about the article.

like image 149
pmg Avatar answered Jan 10 '23 04:01

pmg