On 30 January 2017 at 06:59, vijay nag wrote: > 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 ? No, because you didn't say "extern inline". That means no extern definition is emitted, and so if the function isn't inlined by the optimisers then you need an extern definition. Since you don't have an extern definition, you get a linker error. If you enable optimisation and the function gets inlined then you don't need an extern definition and the program links. > 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. This is all explained at https://gcc.gnu.org/gcc-5/porting_to.html and is just how C99 works.