benben wrote:[color=blue]
> "John" <weekender_ny@yahoo.com> wrote in message
> news:1128053226.420703.320830@o13g2000cwo.googlegr oups.com...[color=green]
> >I am using two large libraries which both have an
> >implementation of a "matrix" class. I have the source code
> >for both. I need to use them in the same project and when I
> >try to compile I get a double declaration conflict. I tried
> >to wrap the smaller library into a namespace but its a
> >nightmare. Is there anyway I could solve this problem without
> >giving up on one of the libraries?[/color][/color]
[...][color=blue]
> Option 2 Use them separately. This means #include'ing
> header(s) of only one of the conflicting libraries in any one
> translation units. This option is preferred when the two
> conflicting libraries can be used in separate places of your
> program, i.e. the uses of them are not intertwined.[/color]
That's not necessarily sufficient. What happens if the two
classes both have defaut constructors, for example. The linker
will pull in at most one, and you'll end up with the constructor
for one of the classes invoked to construct instances of the
other.
[color=blue]
> Option 3 Provide wrapper classes/functions for one of the two
> libraries or both. Put your own abstractions in separate
> namespaces and only #include the troublesome library headers
> in the implementation of your own abstraction layer (so by
> #including your own abstraction layer headers won't pull in
> the library headers). This potentially can be expensive but it
> always works.[/color]
It shares the same problem with linking as the above.
It can be made to work if you put the two matrix classes in
separate dynamically loaded objects.
--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
[ See
http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]