I've found a work around for now using "static inline" rather than
"extern inline" in C++ code. Since the 2.x branch of GCC is no longer
being maintained, I guess an important question is whether or not this
problem exists in GCC 3.1. Can someone try this out, please?
On Mon, May 13, 2002 at 10:05:14PM -0500, Dave Dribin wrote:
> I have found this obscure bug when combining inline code, C++, and C
> code. The problem only manifests itself when compiling with
> optimizations off. I am using the MinGW 1.1 package on Win98. I've
> attached a zip that demonstrates the problem. To see the error, build
> like this:
> % make OPTIMIZE=0 USE_C_MODULE=0
> I get a "multiple definition of `calc_double'" error at link time.
> If you turn off optimizations or use a C version of the C++ module,
> the program links fine, i.e. these both build fine:
> % make OPTIMIZE=1 USE_C_MODULE=0
> % make OPTIMIZE=0 USE_C_MODULE=1
> BTW, the same code compiles under Linux with gcc 2.96 and DJGPP with
> gcc 2.95 without errors in all three cases. It looks as if g++ uses
> weak symbols under Linux and DJGPP for inlne functions w/o
> optimizations, but on MinGW, it is a strong symbol. This strong
> symbol conflicts with the symbol in inline.o.