Skip to content

Instantly share code, notes, and snippets.

@hidsh
Created July 30, 2025 11:12
Show Gist options
  • Save hidsh/3a9921ca43caed8a7e64a924e11d387e to your computer and use it in GitHub Desktop.
Save hidsh/3a9921ca43caed8a7e64a924e11d387e to your computer and use it in GitHub Desktop.
c example for inline functions
#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