Skip to content

Instantly share code, notes, and snippets.

@Ludo6431
Created June 23, 2011 00:20
Show Gist options
  • Save Ludo6431/1041619 to your computer and use it in GitHub Desktop.
Save Ludo6431/1041619 to your computer and use it in GitHub Desktop.
What makes including inline functions in headers impossible ?
#include <stdlib.h>
#include <stdio.h>
#include "test.h"
int main(int argc, char *argv[]) {
printf("inl_fun:%d\n", inl_fun(4));
printf("ninl_fun:%d\n", ninl_fun(4));
return 0;
}
#include <stdlib.h>
#include <stdio.h>
#include "test.h"
int ninl_fun(int arg) {
return -arg;
}
#ifndef _TEST_H
#define _TEST_H
#include <assert.h>
static inline int inl_fun(int arg) {
assert(arg>=0);
return -arg;
}
int ninl_fun(int arg);
#endif
@Ludo6431
Copy link
Author

inline => static inline
perfect!
ty WM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment