inline functions

Muni Sekhar munisekharrms at gmail.com
Sat Jun 4 10:59:05 EDT 2016


Hi,

I tested with the below mentioned code("inline.c") to understand about
inline functions.

I explicitly instructed gcc to translate inline.c to inline.s.

Next I removed the inline keyword from inline.c and re-created the
inline.s file, but I don’t see any difference in the assembly code. Is
it correct behavior?

Could you guys point few good examples to understand the concept of inline?



#include <stdio.h>

static inline int MAX(int x, int y) { return x > y ? x : y; }

static void test1(void);


int main(void)
{
        test1();
        return 0;
}

static void test1(void)
{
        printf("MAX(2,6) = %d\n",MAX(2,6));
}


-- 
Thanks,
Sekhar



More information about the Kernelnewbies mailing list