using gcc 3.0.1 and 2.95.2.1

Michael Veksler VEKSLER@il.ibm.com
Tue Sep 11 05:44:00 GMT 2001


> > "iosfwd.h" is a file I wrote that includes iosfwd, and has
> > several "using std::one-of-iostream-classes;" lines.
>
> Where can i find that file?
> i would like to try this workaround.I would need kdevelop in a short.

It is trivial to write, just read vector.h in gcc-3.0 and use it
as an example. I don't want to give you the actual file
(company copyright policy I don't want to check and learn).
It should look something like:

// iosfwd.h
#ifndef _IOSFWD_H
#define _IOSFWD_H
#include <iosfwd>
using std::istream; // this is probably enough for flex.
// Put here other things that you find in iosfwd
// and prefix them with "using std::"
#endif


> > Maybe recompile every single C++ library you have with the same C++
> > compiler?
>
> Argh!
> so, should i go back to 2.95.2 or some other older compiler ( i dont want
toi
> do this unless i am REALLY desperate) or try to fix problems as they
came?
If you know what was compiled with what version, then you only have to
recompile libraries you depend on and are from the "wrong" version.
If you used shared libraries, then it should be simple - just run ldd on
the library in question and you will see what libstdc++.so it uses.

> > It *may* be possible to mix two different C++ versions in a single
program
> > by using C or CORBA proxies, but I guess you are not that desperate.
>
> Can you explain better? i am NOT so desperate but i am curious.

You can read about CORBA on the net.
C proxy can be something like this (CORBA auto-generated code has
similarities
with this example):

// A.h
// This is the original class compiled with gcc-2.95
class A {
public:
   int get();
  void set(int a);
};

// proxy.h
extern "C" {
struct proxy_A;   // this gives minimal type checking
int A_get(proxy_A *object);
void A_set(proxy_A *object, int a);
proxy_A * A_new();
void A_delete(proxy_A*);
};

// proxy2-95.cpp - compiled with gcc-2.95
#include "A.h"
#include "proxy.h"
int A_get(proxy_A *object)
{
  return ((A*)object)->get();
}
void A_set(proxy_A *object, int a)
{
  ((A*)object)->set(a);
}
// etc.


// proxy3.h - included by code compiled with  gcc-3.0
namespace Gcc3 {
  class A {
  public:
     A() { _value = A_new(); }
     // do something for copy ctor and assignment...
    ~A() { A_delete(_value) };
     int get() { return A_get(_value); }
    void set(int a) { A_set(_value, a); }
  private:
   proxy_A *_value;
  };
};
using namespace Gcc3;

/// end example


Note that this may not work due to clashing libstdc++. You may overcome
that by dlopen tricks (and in that case you don't need namespace Gcc3).
As you see, it can be done, but doing it manually is not very nice.




More information about the Gcc-help mailing list