* Trouble inlining code
@ 2006-02-10 21:04 securehell
2006-02-10 21:11 ` Sven Eschenberg
2006-02-11 9:39 ` "Sébastien L."
0 siblings, 2 replies; 4+ messages in thread
From: securehell @ 2006-02-10 21:04 UTC (permalink / raw)
To: gcc-help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello group,
I am trying to inline a function with gcc-3.4.4 on a linux x86_64
platform.
The function I am trying to inline is in a header file:
foo.h:
inline int *your_func(int *a) { if (!a) return (NULL); return
(*a++);}
Any file that I compile that includes this header and code compiles
without error:
gcc -m64 -c -Wall -Winline -fPIC -O3 -o bar.o bar.c
But when I try to link, I get a mess...
/usr/bin/gcc -shared -Wl,--whole-archive -Wall -Winline -fPIC -o
libfiles.so file.o libfoo.a -Wl,--no-whole-archive
libfoo.a(file.o)(.text+0x0): In function `my_func':
: multiple definition of `your_func'
libfoo.a(bar.o)(.text+0x0): first defined here
What could I be missing that will inline this function for me?
Thanks,
SH
-----BEGIN PGP SIGNATURE-----
Note: This signature can be verified at https://www.hushtools.com/verify
Version: Hush 2.4
wkYEARECAAYFAkPs/8EACgkQRBFe1uc9INoi7gCaAkhb9S5rcYWmyEwmvK34mILqH1UA
oJmf9uXEUpXxMYmIYoil2WrYz246
=wiWt
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Trouble inlining code
2006-02-10 21:04 Trouble inlining code securehell
@ 2006-02-10 21:11 ` Sven Eschenberg
2006-02-11 9:39 ` "Sébastien L."
1 sibling, 0 replies; 4+ messages in thread
From: Sven Eschenberg @ 2006-02-10 21:11 UTC (permalink / raw)
To: gcc-help
Hi,
you might want to check:
http://www.greenend.org.uk/rjk/2003/03/inline.html
Esp. the part with the examples ... I think what you want is a static
inline (not absolutely sure though)
Greets
-Sven
securehell@hushmail.com wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Hello group,
>
>I am trying to inline a function with gcc-3.4.4 on a linux x86_64
>platform.
>
>The function I am trying to inline is in a header file:
>
>foo.h:
>
>inline int *your_func(int *a) { if (!a) return (NULL); return
>(*a++);}
>
>Any file that I compile that includes this header and code compiles
>without error:
>
>gcc -m64 -c -Wall -Winline -fPIC -O3 -o bar.o bar.c
>
>But when I try to link, I get a mess...
>
>/usr/bin/gcc -shared -Wl,--whole-archive -Wall -Winline -fPIC -o
>libfiles.so file.o libfoo.a -Wl,--no-whole-archive
>
>libfoo.a(file.o)(.text+0x0): In function `my_func':
>: multiple definition of `your_func'
>libfoo.a(bar.o)(.text+0x0): first defined here
>
>What could I be missing that will inline this function for me?
>
>Thanks,
>
>SH
>-----BEGIN PGP SIGNATURE-----
>Note: This signature can be verified at https://www.hushtools.com/verify
>Version: Hush 2.4
>
>wkYEARECAAYFAkPs/8EACgkQRBFe1uc9INoi7gCaAkhb9S5rcYWmyEwmvK34mILqH1UA
>oJmf9uXEUpXxMYmIYoil2WrYz246
>=wiWt
>-----END PGP SIGNATURE-----
>
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Trouble inlining code
2006-02-10 21:04 Trouble inlining code securehell
2006-02-10 21:11 ` Sven Eschenberg
@ 2006-02-11 9:39 ` "Sébastien L."
1 sibling, 0 replies; 4+ messages in thread
From: "Sébastien L." @ 2006-02-11 9:39 UTC (permalink / raw)
To: gcc-help
Hi,
It seems your function is defined several times : multiple definition of
`your_func'
May be this is a stupid advice, but didn't you forget the classic #ifndef ?
#if !defined(MY_HEADER)
#define MY_HEADER
... my header content and inline definitions ...
#endif
Hopes this help.
S.L.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Trouble inlining code
@ 2006-02-10 21:27 securehell
0 siblings, 0 replies; 4+ messages in thread
From: securehell @ 2006-02-10 21:27 UTC (permalink / raw)
To: gcc-help, eschenb
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
"static inline" did the trick.
Danke shoene.
SH
On Fri, 10 Feb 2006 16:11:52 -0500 Sven Eschenberg <eschenb@cs.uni-
frankfurt.de> wrote:
>Hi,
>
>you might want to check:
>
>http://www.greenend.org.uk/rjk/2003/03/inline.html
>
>Esp. the part with the examples ... I think what you want is a
>static
>inline (not absolutely sure though)
>
>Greets
>
>-Sven
>
>securehell@hushmail.com wrote:
>
>>-----BEGIN PGP SIGNED MESSAGE-----
>>Hash: SHA1
>>
>>Hello group,
>>
>>I am trying to inline a function with gcc-3.4.4 on a linux x86_64
>>platform.
>>
>>The function I am trying to inline is in a header file:
>>
>>foo.h:
>>
>>inline int *your_func(int *a) { if (!a) return (NULL); return
>>(*a++);}
>>
>>Any file that I compile that includes this header and code
>compiles
>>without error:
>>
>>gcc -m64 -c -Wall -Winline -fPIC -O3 -o bar.o bar.c
>>
>>But when I try to link, I get a mess...
>>
>>/usr/bin/gcc -shared -Wl,--whole-archive -Wall -Winline -fPIC -o
>>libfiles.so file.o libfoo.a -Wl,--no-whole-archive
>>
>>libfoo.a(file.o)(.text+0x0): In function `my_func':
>>: multiple definition of `your_func'
>>libfoo.a(bar.o)(.text+0x0): first defined here
>>
>>What could I be missing that will inline this function for me?
>>
>>Thanks,
>>
>>SH
>>-----BEGIN PGP SIGNATURE-----
>>Note: This signature can be verified at
>https://www.hushtools.com/verify
>>Version: Hush 2.4
>>
>>wkYEARECAAYFAkPs/8EACgkQRBFe1uc9INoi7gCaAkhb9S5rcYWmyEwmvK34mILqH1
>UA
>>oJmf9uXEUpXxMYmIYoil2WrYz246
>>=wiWt
>>-----END PGP SIGNATURE-----
>>
>>
>>
>>
-----BEGIN PGP SIGNATURE-----
Note: This signature can be verified at https://www.hushtools.com/verify
Version: Hush 2.4
wkYEARECAAYFAkPtBT0ACgkQRBFe1uc9INqfYwCeMEkljlCSm1O56q/0h1PmlWy+bP4A
n1FQmyhH09R9rmv7AyXoviRNvcOn
=t5j0
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-02-11 9:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-10 21:04 Trouble inlining code securehell
2006-02-10 21:11 ` Sven Eschenberg
2006-02-11 9:39 ` "Sébastien L."
2006-02-10 21:27 securehell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).