This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Deja Vu: multiple definition of `java::lang::String::length()'?
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- To: Adam Megacz <gcj at lists dot megacz dot com>
- Cc: java at gcc dot gnu dot org
- Date: Tue, 12 Mar 2002 13:34:31 +1300
- Subject: Re: Deja Vu: multiple definition of `java::lang::String::length()'?
- References: <86zo1hur69.fsf@megacz.com> <86zo1fnea4.fsf@megacz.com>
Adam Megacz wrote:
>This is actually caused by gcjh -- it generates a function body for
>simple functions, like this:
>
> jint length () { return count; }
>
>Now this is cool, since it lets gcc inline simple methods, but OTOH it
>causes link failures since you now have two definitions of
>java::lang::String::length() (one in C++ from the headers, and one in
>Java from String.java).
>
Aah, ok. Presumably you are compiling without -O, otherwise it would get
inlined and there wouldn't be a problem?
>Is this only a problem on mingw due to lack of weak symbols? I haven't
>tried it on any other platforms. Sticking an 'inline' in front of the
>jint doesn't help, and C++ doesn't provide a way to specify internal
>linkage for a method ('static' has a different meaning for methods
>than for functions, AFAICT).
>
How about __attribute__ ((always_inline)) ?
regards
Bryce.