This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: g++: a bug or a feature ???
- From: Nathan Sidwell <nathan at acm dot org>
- To: Yzhar Keysar <yzhark at milk>
- Cc: gcc at gcc dot gnu dot org, gcc-help at gcc dot gnu dot org
- Date: Wed, 17 Jul 2002 09:26:42 +0100
- Subject: Re: g++: a bug or a feature ???
- References: <GZDW4J00.O3H@antares.silicon-value.com>
- Reply-to: nathan at compsci dot bristol dot ac dot uk
Yzhar Keysar wrote:
> when writing two fuctors ( or for simplicity : inline functions ) with
> the same prototype ( i.e. signature) but in different objects ,
> I get no warning in compile time nor in linkage time. and runtime uses
> only ONE copy of them.
As you realise, you are breaking the one definition rule [3.2].
> //main.cc
> #include <iostream>
> #include "test.hh"
>
> inline void g() { cerr<<"Main.g()\n" ; }
you could make this static inline, if it only in one source file.
you could use namespaces (like the unnamed namespace)
namespace {
inline void g ().....
}
void main () ...
of course it would be nice if the linker could check that two
merged symbols 'came from the same place' (but that's sometimes
not well defined).
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
The voices in my head told me to say this
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk