P
pozz
I'm creating a small library (mylib.c and mylib.h) and I want the
compiler expands
some functions (foo1() and foo2()) inline, both inside mylib.c and in
a second module
(main.c).
My compiler allows inline expansion with #pragma.
-- mylib.h --
#pragma inline foo1, foo2
void foo1(void)
{
...
}
void foo2(void)
{
...
}
--
-- mylibc.c --
#include "mylib.h"
void foo(void)
{
...
foo1();
...
foo2();
...
}
--
-- main.c --
#include "mylib.h"
int main(int argc, char *argv[])
{
...
foo1();
...
foo2();
...
}
--
The linking process gives two warnings, one for each function:
duplicate symbol definition.
Indeed foo1() and foo2() functions are correctly expanded inline (both
in main.c and mylib.c),
but they are expanded as a function per se in both files.
Of course the linker notes two definition of the same symbols.
I tried to declare static foo1() and foo2() in mylib.h, and it works
great. The compilation and
linking processes work great. However in this case I have another
problem. If in a third module
(module.c) I include mylib.h, but I don't use inline functions (foo1()
and/or foo2()) the compiler
gives another warning: static symbol defined but not used.
Any suggestions?
compiler expands
some functions (foo1() and foo2()) inline, both inside mylib.c and in
a second module
(main.c).
My compiler allows inline expansion with #pragma.
-- mylib.h --
#pragma inline foo1, foo2
void foo1(void)
{
...
}
void foo2(void)
{
...
}
--
-- mylibc.c --
#include "mylib.h"
void foo(void)
{
...
foo1();
...
foo2();
...
}
--
-- main.c --
#include "mylib.h"
int main(int argc, char *argv[])
{
...
foo1();
...
foo2();
...
}
--
The linking process gives two warnings, one for each function:
duplicate symbol definition.
Indeed foo1() and foo2() functions are correctly expanded inline (both
in main.c and mylib.c),
but they are expanded as a function per se in both files.
Of course the linker notes two definition of the same symbols.
I tried to declare static foo1() and foo2() in mylib.h, and it works
great. The compilation and
linking processes work great. However in this case I have another
problem. If in a third module
(module.c) I include mylib.h, but I don't use inline functions (foo1()
and/or foo2()) the compiler
gives another warning: static symbol defined but not used.
Any suggestions?