This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: gcc can not distinguish the same file or same class with the different module or library
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Mon, 20 Aug 2007 16:22:56 +0100
- Subject: RE: gcc can not distinguish the same file or same class with the different module or library
- References: <c5afeb490708200216i6a8af644od55a2a113d672edd@mail.gmail.com>
- Reply-to: <gcc at gcc dot gnu dot org>
On 20 August 2007 10:16, summer xia wrote:
> Hello all.
>
> I am porting a application from Windows into Linux.
This list is about internal development of the gcc compiler itself. For
help about the use of the compiler and programming, please use the gcc-help
list. (I have set the follow-up to point there). However, just to quickly
answer:
> when I use these libraries. I alway find that the gcc link the error
> class(I use the gdb to debug it), such as when I use the class CSky in
> the module B, I suppose that this class should use this module
> internal implement( this is to say use CSky implement in the library
> B). But it is surprised to me that CSky uses the library A implement.
> I wonder to know whether it is a bug to gcc or a feature that all
> modules must use the different class name or use the namesapce to
> distinguish these same class name.
It is absolutely the case that you must use different classes or namespaces
to separate the two implementations; otherwise you are violating the ODR (One
Definition Rule), which is a fundamental rule of the C++ language spec.
Combining incompatible libraries that use some of the same names is one of the
main uses of namespaces.
cheers,
DaveK
--
Can't think of a witty .sigline today....