Created
April 29, 2013 20:14
-
-
Save ben/5484410 to your computer and use it in GitHub Desktop.
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 "test.h" | |
extern int foo(char c); | |
int bar(char c) { | |
return foo(c); | |
} |
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
static __inline int foo(char c) { | |
return (int)c; | |
} | |
int bar(char c); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Ben,
Not that this is relevant anymore for libgit2.
However, the following should work in C99:
As the header:
And the c file
If you compile this with gcc you will get an error because gcc by default does not use the c99 standard. But
if you compile it with
gcc -std=c99 -shared
it will create export the symbol test and also have it as inline if you include thetest.h
file.As far as I know this is not supported by VS. But, I am pretty sure that this is what the C99 standard requires.
(Now VS does not claim to support C99)
Oh, BTW that
static
thing for inline is indeed required for pre C99 compilers because otherwise multiple .c files which include the header will create link/compile conflicts. But for C99 this is fine because it requires in the standard that multiple (identical) inline definitions are considered the same.