This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: g++: a bug or a feature ???


> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]