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
On Sat, Jun 4, 2016 at 11:59 AM, Muni Sekhar <munisekharrms@gmail.com> wrote:
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?
Hi Muni, Probably gcc is automatic inlining your function even in the absence of 'inline' keyword... Take a look here: http://www.cocoabuilder.com/archive/xcode/269025-how-to-disable-gcc-automati... And here: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html There are a few inline related flags, including this: -finline-functions-called-once Consider all static functions called once for inlining into their caller even if they are not marked inline. If a call to a given function is integrated, then the function is not output as assembler code in its own right. Enabled at levels -O1, -O2, -O3 and -Os. Best regards, -- Augusto Mecking Caringi
On Sat, Jun 4, 2016 at 9:08 PM, Augusto Mecking Caringi <augustocaringi@gmail.com> wrote:
On Sat, Jun 4, 2016 at 11:59 AM, Muni Sekhar <munisekharrms@gmail.com> wrote:
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?
Hi Muni,
Probably gcc is automatic inlining your function even in the absence of 'inline' keyword...
Take a look here:
http://www.cocoabuilder.com/archive/xcode/269025-how-to-disable-gcc-automati...
Thanks Augusto.
And here:
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
There are a few inline related flags, including this:
-finline-functions-called-once Consider all static functions called once for inlining into their caller even if they are not marked inline. If a call to a given function is integrated, then the function is not output as assembler code in its own right. Enabled at levels -O1, -O2, -O3 and -Os.
Best regards,
-- Augusto Mecking Caringi
-- Thanks, Sekhar
participants (2)
-
Augusto Mecking Caringi -
Muni Sekhar