RE: undefined errors for inline function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux