This is the mail archive of the gcc-help@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


Hello all

But I have a little confused on this quesion. As we all known, there
are lots of open sources can be complied into share object, it is very
hard difficulty to make sure that every module has  unique function /
gobal varible /class name on a application scope. For example when I
develop a applicaion that need FFmpeg shared lib , SDL shared lib, and
directFB shared lib. If these modules have the same function named
foo_dump and their own implement. the application would not be runned
correctly according to ODR (One Definition Rule).

Does GCC have any flags to control which functions can be used by the
user when I complie the codes into a shared object(library)? There is
a dllexport declare to a function or class on Windows OS. Does any the
same flag on Linux OS?

Appreciate for any kind help.

Regards

XiaGuangTai

2007-8-22

On 8/21/07, summer xia <xiaguangt@gmail.com> wrote:
> hello DaveK and Andrew.
>
> Thanks. Now I am clear on this question and know where I send my
> question on how to use gcc.:-)
>
> Thanks for your kind help again.
>
> Regards
>
> XiaGuangTai
>
> 2007-8-21
>
>
> On 8/20/07, Dave Korn <dave.korn@artimi.com> wrote:
> > 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]