This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Inlining function pointers
- From: Ian Lance Taylor <iant at google dot com>
- To: yavuz yetim <yavuzyetim at hotmail dot com>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Tue, 25 Aug 2009 22:43:19 -0700
- Subject: Re: Inlining function pointers
- References: <SNT109-W13504785278D15D696BCD9C2F70@phx.gbl>
yavuz yetim <yavuzyetim@hotmail.com> writes:
> I am using GTree in GLib and the g_tree_foreach() -shown below- function takes a function pointer to call a function (say comp()) for each node while traversing the tree.
> If I declare the function to be inlined and compile it, gcc comlains with following message:
> /var/folders/eh/ehsWlP8bFe8W4KcsmZuVyk+++TI/-Tmp-//ccXexCH9.s:2592:non-relocatable subtraction expression, "_str_print" minus "L00000000006$pb"
> /var/folders/eh/ehsWlP8bFe8W4KcsmZuVyk+++TI/-Tmp-//ccXexCH9.s:2592:symbol: "_str_print" can't be undefined in a subtraction expression
>
>
>
> somewhere in main:: g_tree_foreach(my_tree, comp, NULL);
> functions::
> inline gboolean comp(/*arguments*/) { /*do stuff*/ return FALSE;}
> /*g_tree_foreach From GLib source*/void g_tree_foreach (GTree *tree, GTraverseFunc func, gpointer user_data){ GTreeNode *node;
> g_return_if_fail (tree != NULL); if (!tree->root) return;
> node = g_tree_first_node (tree); while (node) { if ((*func) (node->key, node->value, user_data)) break; node = g_tree_node_next (node); }}
This looks like a compiler bug but it's hard to be certain. I don't see
anything named _str_print in your code sample. Please give us a
complete small test case. Please also tell us what version of gcc you
are using, and what target you are compiling for.
Ian