This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: undefined errors for inline function


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]