This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: undefined errors for inline function
- From: vijay nag <vijunag at gmail dot com>
- To: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 30 Jan 2017 12:29:59 +0530
- Subject: RE: undefined errors for inline function
- Authentication-results: sourceware.org; auth=none
Hello GCC,
I get linker error when I define/declare a function as inline in C
file when -std=c99 flags are passed. Why is compiler treating the
below Foo func as undefined although it is defined in the same
file(The symbol is U on nm output) ? Is compiler treating the function
as extern inline by default ?
However, it compiles fine without -std=c99 flags. Also, it compiles
fine with std=c99 flags when the definition/declaration is changed to
static inline instead of just inline.
Gcc version: 4.8.4
cat linker.c
#include <stdio.h>
inline int Foo(long a, long b);
inline int Foo(long a, long b) {
}
int main() {
Foo(1, 3);
}
Ubuntu:~]#gcc linker.c -std=c99
/tmp/ccddb43a.o: In function `main':
linker.c:(.text+0xf): undefined reference to `Foo'
collect2: error: ld returned 1 exit status