This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: static inline operator generates an external symbol
- To: sean at mcneil dot com
- Subject: Re: static inline operator generates an external symbol
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Fri, 14 Jan 2000 22:53:49 +0100
- CC: gcc-bugs at gcc dot gnu dot org
- References: <387F6D00.C362CA00@mcneil.com>
> I'm in a situation where I need to overload the standard new/delete
> operators for a portion of my code. I defined them as static inline
> inside an include file and everything compiles. When I go to link,
> however, I get multiple definitions of __builtin_new, etc. Those
> static inline operators are being exported. Is this a bug?
Thanks for your bug report. This is a bug, both in your code, and in
gcc. The bug in your code is that operator new is declared extern, and
later declared static. The bug in g++ is that it does not detect this
incorrect redeclaration.
> Is there a better way to do this? There are too many object types
> to overload for each of them.
You could declare the operator new in a base class only. Other than
that, there is no alternative. C++ does not support file-local
allocation mechanisms.
Regards,
Martin