Skip to content

Instantly share code, notes, and snippets.

@ben
Created April 29, 2013 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ben/5484410 to your computer and use it in GitHub Desktop.
Save ben/5484410 to your computer and use it in GitHub Desktop.
#include "test.h"
extern int foo(char c);
int bar(char c) {
return foo(c);
}
static __inline int foo(char c) {
return (int)c;
}
int bar(char c);
@woudshoo
Copy link

Hi Ben,

Not that this is relevant anymore for libgit2.
However, the following should work in C99:

As the header:

inline int test (void) 
{
  return 10;
}

And the c file

#include "test.h"

int test ();

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 the test.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.

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