<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>l;inking with an inline function</title>
<description> I&amp;#039;m having problems linking to a function that I made and have declared inline. I have it declared in fileA.c and I have it in fileA.h, but when I try to use it in fileB.c which has fileA.h included it doesn&amp;#039;t find the function. 

Here is an example:
FileA.c:

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.



I know everything is set up right, because when it isn&amp;#039;t declared inline then it works fine. Is there any way to fix this. My function is called a few times and is only one line long, so it would be nice to be inlined, but it isn&amp;#039;t crucial.

I believe that this is caused by gcc deleting the code for the function after it has been compiled. If so, is there any way to stop this from happening?

Thanks</description><link>http://forum.wiibrew.org/read.php?11,59554,59554#msg-59554</link><lastBuildDate>Sun, 10 May 2026 22:07:04 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,59554,59624#msg-59624</guid>
<title>Re: l;inking with an inline function</title><link>http://forum.wiibrew.org/read.php?11,59554,59624#msg-59624</link><description><![CDATA[ Ok that would explane my errors. So that means it has to be declared with the code in every c file I plane to use it in?]]></description>
<dc:creator>g_man</dc:creator>
<category>Coding</category><pubDate>Tue, 21 Sep 2010 15:32:59 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,59554,59580#msg-59580</guid>
<title>Re: l;inking with an inline function</title><link>http://forum.wiibrew.org/read.php?11,59554,59580#msg-59580</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>g_man</strong><br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong>tueidj</strong><br />Putting a function&#039;s code in a header file is basically the same as declaring it inline, except you avoid multiple definition errors by using inline.</div></blockquote>are you sure? but declaring it static inline would also solve the same problem.</div></blockquote>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".<br /><br />More on gcc and inline can be found here: [<a href="http://gcc.gnu.org/onlinedocs/gcc/Inline.html" rel="nofollow">gcc.gnu.org</a>]]]></description>
<dc:creator>Daid</dc:creator>
<category>Coding</category><pubDate>Mon, 20 Sep 2010 13:20:07 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,59554,59574#msg-59574</guid>
<title>Re: l;inking with an inline function</title><link>http://forum.wiibrew.org/read.php?11,59554,59574#msg-59574</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>tueidj</strong><br />Putting a function&#039;s code in a header file is basically the same as declaring it inline, except you avoid multiple definition errors by using inline.</div></blockquote>are you sure? but declaring it static inline would also solve the same problem.]]></description>
<dc:creator>g_man</dc:creator>
<category>Coding</category><pubDate>Mon, 20 Sep 2010 05:37:16 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,59554,59573#msg-59573</guid>
<title>Re: l;inking with an inline function</title><link>http://forum.wiibrew.org/read.php?11,59554,59573#msg-59573</link><description><![CDATA[ Putting a function&#039;s code in a header file is basically the same as declaring it inline, except you avoid multiple definition errors by using inline.]]></description>
<dc:creator>tueidj</dc:creator>
<category>Coding</category><pubDate>Mon, 20 Sep 2010 05:21:36 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,59554,59569#msg-59569</guid>
<title>Re: l;inking with an inline function</title><link>http://forum.wiibrew.org/read.php?11,59554,59569#msg-59569</link><description><![CDATA[ that makes sense, but isn&#039;t it bad practice to put c code in a header file. Would it be a better idea to just copy the code and put it in fileB.c.]]></description>
<dc:creator>g_man</dc:creator>
<category>Coding</category><pubDate>Mon, 20 Sep 2010 00:01:39 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,59554,59568#msg-59568</guid>
<title>Re: l;inking with an inline function</title><link>http://forum.wiibrew.org/read.php?11,59554,59568#msg-59568</link><description><![CDATA[ Inline happens at compile time not at link time, so that&#039;s why it won&#039;t link (as the function is already inlined) the only way to get inline functions to work is to put the whole implementation in the header file. (for best compiler compatibility make the function "static inline")]]></description>
<dc:creator>Daid</dc:creator>
<category>Coding</category><pubDate>Sun, 19 Sep 2010 22:30:39 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,59554,59554#msg-59554</guid>
<title>l;inking with an inline function</title><link>http://forum.wiibrew.org/read.php?11,59554,59554#msg-59554</link><description><![CDATA[ I&#039;m having problems linking to a function that I made and have declared inline. I have it declared in fileA.c and I have it in fileA.h, but when I try to use it in fileB.c which has fileA.h included it doesn&#039;t find the function.<br /><br />Here is an example:<br />FileA.c:<br /><pre class="bbcode">
float inline myInlineFunc(int foo,int bar){
return foo/bar;
}</pre>
FileA.h:<br /><pre class="bbcode">
float inline myInlineFunc(int foo,int bar);</pre>
FileB.c:<br /><pre class="bbcode">
#include FileB.h

myInlineFunc(5,3); //This line gives me a linking error.</pre><br /><br /><br />I know everything is set up right, because when it isn&#039;t declared inline then it works fine. Is there any way to fix this. My function is called a few times and is only one line long, so it would be nice to be inlined, but it isn&#039;t crucial.<br /><br />I believe that this is caused by gcc deleting the code for the function after it has been compiled. If so, is there any way to stop this from happening?<br /><br />Thanks]]></description>
<dc:creator>g_man</dc:creator>
<category>Coding</category><pubDate>Sun, 19 Sep 2010 06:31:08 +0200</pubDate></item>
</channel>
</rss>