g++: a bug or a feature ???
mike stump
mrs@windriver.com
Tue Jul 9 11:23:00 GMT 2002
> Date: Tue, 9 Jul 2002 17:34:25 +0300 (IDT)
> From: Yzhar Keysar <yzhark@milk.silicon-value.com>
> To: <gcc@gcc.gnu.org>
> 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.
Welcome to C++. You've just violated one of the rules of the lanuage
for which there is no warning or error message. This is not a bug, it
is how C++ is.
> the problem is that in a large project, I could choose by mistake an
> already existed function prototype but have a different implementation.
You can use static to tell the compiler that you don't want any
linkage between the two. The use of static is covered in manny books
on C and C++. Beyond this, you can use namespaces or classes to solve
the problem as well.
This is more about how to program in C/C++, and comp.lang.c++ would be
a better forum.
More information about the Gcc
mailing list