I'm compiling my code with the -std=gnu17 flag, and from what I've inferred, it follows the gnu89 inline semantics.
According to the GCC manual:
This combination of inline and extern has almost the effect of a macro. The way to use it is to put a function definition in a header file with these keywords, and put another copy of the definition (lacking inline and extern) in a library file. The definition in the header file causes most calls to the function to be inlined. If any uses of the function remain, they refer to the single copy in the library.
In foo.h:
extern inline int bar(int src)
{
int dst;
asm ("mov %1, %0\n\t"
"add $1, %0"
: "=r" (dst)
: "r" (src));
return dst;
}
In foo.c:
#include "foo.h"
int bar(int src)
{
int dst;
asm ("mov %1, %0\n\t"
"add $1, %0"
: "=r" (dst)
: "r" (src));
return dst;
}
In test.c:
#include <stdio.h>
#include "foo.h"
int main()
{
int a = 1;
printf("%d\n", bar(a));
return 0;
}
I get the following error on compiling with gcc -std=gnu17 foo.c test.c:
foo.c:3:5: error: redefinition of 'bar'
3 | int bar(int src)
| ^~~
In file included from foo.c:1:
foo.h:1:19: note: previous definition of 'bar' with type 'int(int)'
1 | extern inline int bar(int src)
| ^~~