0

I have this:

inline void ololo(int a) {
    printf(a);
}

int main() {
    int b = 100;
    ololo(b);
}

When I try to build program with gcc filename.c, I get this error message:

/tmp/ccJovQFR.o: In function `main':
trololo.c:(.text+0x3b): undefined reference to `ololo'
collect2: error: ld returned 1 exit status
Daniel
  • 11
  • 2
  • 1
    I can reproduce your problem, but there's others. Be sure to first clean up all the other warnings (set `-Wall`). That's not now you use `printf`. – Schwern Nov 02 '16 at 19:14
  • Show us whole code, this one is invalid and will not compile. – Michał Walenciak Nov 02 '16 at 19:14
  • @MichałWalenciak Well, it *does compile* with gcc by default, but it also emits some warnings (-Wimplicit-function-declaration and -Wint-conversion). – Jonas Schäfer Nov 02 '16 at 19:16
  • This is a c99 feature (`extern inline`). This documentation from clang has a good explanation on it. Other compilers should have something similar, too. http://clang.llvm.org/compatibility.html#inline – user3528438 Nov 02 '16 at 19:18
  • @JonasWielicki: that's weird: printf should not accept int as an argument. As long as it is not some kind of extension... – Michał Walenciak Nov 02 '16 at 19:41
  • @MichałWalenciak It’s an implicit cast from int to const char*, hence the -Wint-conversion warning. – Jonas Schäfer Nov 02 '16 at 19:49

0 Answers0