1 | #include <stdio.h> |
---|---|
2 | |
3 | #define INLINE inline __attribute__((always_inline)) |
4 | |
5 | int |
6 | func_not_inlined (void) |
7 | { |
8 | printf (format: "Called func_not_inlined.\n"); |
9 | return 0; |
10 | } |
11 | |
12 | INLINE int |
13 | func_inlined (void) |
14 | { |
15 | static int func_inline_call_count = 0; |
16 | printf (format: "Called func_inlined.\n"); |
17 | ++func_inline_call_count; // Set break point at this line. |
18 | printf (format: "Returning func_inlined call count: %d.\n", func_inline_call_count); |
19 | return func_inline_call_count; |
20 | } |
21 | |
22 | extern int func_inlined (void); |
23 | |
24 | int |
25 | main (int argc, char **argv) |
26 | { |
27 | printf (format: "Starting...\n"); |
28 | |
29 | int (*func_ptr) (void); |
30 | func_ptr = func_inlined; |
31 | |
32 | int a = func_inlined(); |
33 | printf(format: "First call to func_inlined() returns: %d.\n", a); |
34 | |
35 | func_not_inlined (); |
36 | |
37 | func_ptr (); |
38 | |
39 | printf(format: "Last call to func_inlined() returns: %d.\n", func_inlined ()); |
40 | return 0; |
41 | } |
42 | |
43 | |
44 |