Re: missing symbols with bobcat C++ library on armel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Frank B. Brokken" <f.b.brokken@xxxxxx> writes:

> class MultiStreambuf: public std::streambuf
> {
>     public:
>         enum Mode
>         {
>             OFF,                // stream not used
>             ON,                 // stream always used
>             ONCE,               // stream used until flushed
>             RESET,              // stream once used. Set to ONCE to re-use
>         };
>
>         class stream            // holds a pointer to a stream and a indicator
>         {                       // telling us whether or not to use the stream
>             friend class MultiStreambuf;
>
>             std::ostream *d_os;
>             Mode          d_mode;
>
>             public:
>                 stream(std::ostream &os, Mode mode = ON);
>                 void setMode(Mode mode);
>                 Mode mode() const;
>                 std::ostream &ostream();
>             private:
>                 static void setOnce(stream &os);
>         };
>
>         typedef std::vector<stream>::iterator iterator;
>         typedef std::vector<stream>::const_iterator const_iterator;
>
>     private:
>         std::string d_buffer;
>         std::vector<stream> d_os;
>
>     public:
>         MultiStreambuf() = default;
>         explicit MultiStreambuf(std::ostream &os, Mode mode = ON);
>         explicit MultiStreambuf(std::vector<stream> const &osvector);
>
>         void insert(std::ostream &os, Mode mode = ON);
>         void insert(std::vector<stream> const &os);
>         iterator begin();
>         iterator end();
>         const_iterator begin() const;
>         const_iterator end() const;
>         void setOnce();             // reset all `RESET' modes to `ONCE'
>         
>     protected:
>         int pSync();
>
>     private:
>         virtual int overflow(int c);
>         virtual std::streamsize xsputn(char const *buffer, std::streamsize n);
>         virtual int sync();
>
>         struct Insert
>         {
>             std::string &buffer;
>             bool ok;
>         };
>         static void insertStruct(stream &os, Insert &insert); 
> };


OK, so the key method should be overflow.



> You won't see the implementations of the private virtual members here, as they
> are provided in the following header file, which is included by
> MultiStreambuf's sources:
>
> -------------------------------------------------------
> #include "multistreambuf"
>
> #include <algorithm>
> #include <bobcat/fnwrap>
>
> using namespace FBB;
>
> inline std::streamsize MultiStreambuf::xsputn(char const *buffer, 
>                                               std::streamsize n)
> {
>     d_buffer.append(buffer, n);
>     return n;
> }
>
> inline int MultiStreambuf::sync()
> {
>     return pSync();
> }
>
> inline int MultiStreambuf::overflow(int c)
> {
>     if (c == EOF)
>         pSync();
>     else 
>         d_buffer += c;
>
>     return c;
> }
> -------------------------------------------------------


This approach will only work if you guarantee that every piece of code
that creates a new MultiStreambuf includes that header file.


> Since it looks like armel's compiler skips the inline definitions of virtual
> members when compiling for a shared library, we're in the process of removing
> all inline definitions of virtual members, replacing them by non-inline
> definitions in separate source files. From tests done so far by George Danchev
> we get the impression that this might very well solve (or bypass?) the issue.

Yes, that should work.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux