Created
June 23, 2011 00:20
-
-
Save Ludo6431/1041619 to your computer and use it in GitHub Desktop.
What makes including inline functions in headers impossible ?
This file contains 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 <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; | |
} |
This file contains 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 <stdlib.h> | |
#include <stdio.h> | |
#include "test.h" | |
int ninl_fun(int arg) { | |
return -arg; | |
} |
This file contains 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
#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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
inline => static inline
perfect!
ty WM