Created
July 30, 2025 11:12
-
-
Save hidsh/3a9921ca43caed8a7e64a924e11d387e to your computer and use it in GitHub Desktop.
c example for inline functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int fun(int x) { return x * 10; } | |
// inline int fun_inline(int x) { return x * 100; } // --> causes undefined reference | |
extern inline int fun_inline(int x) { return x * 100; } // ok | |
// static inline int fun_inline(int x) { return x * 1000; } // ok, but this .c file local | |
int main(void) { | |
printf("%d, %d\n", fun(2), fun_inline(2)); | |
} | |
/* | |
20, 200 | |
or | |
20, 2000 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment