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: gcc can not distinguish the same file or same class with the different module or library


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


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