gcc can not distinguish the same file or same class with the different module or library
Dave Korn
dave.korn@artimi.com
Mon Aug 20 21:40:00 GMT 2007
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....
More information about the Gcc
mailing list