l;inking with an inline function September 19, 2010 06:31AM | Registered: 15 years ago Posts: 444 |
float inline myInlineFunc(int foo,int bar){ return foo/bar; }FileA.h:
float inline myInlineFunc(int foo,int bar);FileB.c:
#include FileB.h myInlineFunc(5,3); //This line gives me a linking error.
Re: l;inking with an inline function September 19, 2010 10:30PM | Registered: 14 years ago Posts: 379 |
Re: l;inking with an inline function September 20, 2010 12:01AM | Registered: 15 years ago Posts: 444 |
Re: l;inking with an inline function September 20, 2010 05:21AM | Registered: 14 years ago Posts: 686 |
Re: l;inking with an inline function September 20, 2010 05:37AM | Registered: 15 years ago Posts: 444 |
Re: l;inking with an inline function September 20, 2010 01:20PM | Registered: 14 years ago Posts: 379 |
Indeed, static would solve the multiple definition errors. The "inline" keyword is just a hint for the compiler, the compiler is free to ignore it if it wants to. Also, in gcc "inline" implies "static".Quote
g_manare you sure? but declaring it static inline would also solve the same problem.Quote
tueidj
Putting a function's code in a header file is basically the same as declaring it inline, except you avoid multiple definition errors by using inline.
Re: l;inking with an inline function September 21, 2010 03:32PM | Registered: 15 years ago Posts: 444 |