inheriting from SkStream

92 views
Skip to first unread message

swagat mishra

unread,
Oct 31, 2012, 9:16:54 AM10/31/12
to skia-d...@googlegroups.com
hi,
While inheriting from SkStream class (i implement  the read and rewind virtual functions in the derived class) i am getting a compiler error of "no typeinfo for SkStream".
My class definition is class SkiaStream: public SkStream.
However, when i try to follow the same pattern as SkMemoryStream, and add the lines
SK_Declare_Inst_count(SkiaStream) SkStream();
and private :typedef SkStream INHERITED;.
i get errors for INHERITED being private.
Can someone help me understand what is the purpose of SK_Declare_inst_count and the typedef are?
Also how do i successfully inherit from SkStream?

Mike Reed

unread,
Oct 31, 2012, 9:38:50 AM10/31/12
to skia-d...@googlegroups.com
What platform are you building on? Are you building with RTTI?
> --
> You received this message because you are subscribed to the Google Groups
> "skia-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/skia-discuss/-/DjcvGS-bheIJ.
> To post to this group, send email to skia-d...@googlegroups.com.
> To unsubscribe from this group, send email to
> skia-discuss...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/skia-discuss?hl=en.

Robert Phillips

unread,
Oct 31, 2012, 9:46:43 AM10/31/12
to skia-d...@googlegroups.com
Hi,
  The instance counting macros allow us to track allocated instances of each class. This lets us spot leaks with out slowing down execution too much. You do not need to add it for your derived class. If any of your objects leak they will show up as leaked SkStream objects.

   Rob

On Wed, Oct 31, 2012 at 9:16 AM, swagat mishra <swagatmi...@gmail.com> wrote:

--

swagat mishra

unread,
Oct 31, 2012, 2:45:20 PM10/31/12
to skia-d...@googlegroups.com

i am building on Android 4.0 platform.
for more details here's the exact class definition i am using:
class SkiaStream : public SkStream

{

public:

    SkiaStream();
   SkiaStream(IStream* stream );
   virtual bool rewind() ;
   const char* getFileName() ;
   virtual size_t read (void* buffer, size_t size) ;
   virtual ~SkiaStream();

};
the exact error i get is: "in function typeinfo for SkiaStream:SkiaStream.cpp(.data.rel.ro+0x2c): error: undefined reference to 'typeinfo for SkStream'"
Message has been deleted

swagat mishra

unread,
Oct 31, 2012, 5:21:44 PM10/31/12
to skia-d...@googlegroups.com
sorry for double post, but i failed to mention another point.
i am trying to extend SkStream from outside skia ( my code includes skia as a library)
when i move the code into Skia and try to compile, it compiles fine.
i also gave a wrong version of my code:
 here's the correct one:
class SkiaStream : public SkStream

{

public:

   explicit SkiaStream(IStream* stream );

    virtual ~SkiaStream();

    virtual const char* getFileName() SK_OVERRIDE;

    virtual bool rewind() SK_OVERRIDE ;

    virtual const void* getMemoryBase() SK_OVERRIDE;

    virtual size_t read (void* buffer, size_t size) SK_OVERRIDE;

    

private:

    IStream *_stream;

};


};

bungeman

unread,
Oct 31, 2012, 5:50:24 PM10/31/12
to skia-d...@googlegroups.com
It's difficult to tell from what you have specified. You may wish to take a look at http://stackoverflow.com/questions/307352/g-undefined-reference-to-typeinfo for more information about different causes. Note that Skia for Android is by default built with -fno-rtti, so you will need to be sure to build your code with this flag or build your Skia library without it. Make sure that you're using your own Skia library and not trying to use the system Skia library directly, as it does not have a stable API. You will also need to be sure everything the linker needs is available, as SkStream has two non-pure non-inline virtual methods (getFileName and getMemoryBase). If the linker can't find these then you will get this error. (Though I'm not sure why they aren't inline, their entire implementation is to just return NULL.)

swagat mishra

unread,
Nov 5, 2012, 6:02:26 AM11/5/12
to skia-d...@googlegroups.com
thanks a lot for the help. the problem was in Android being built with -fno-rtti.
Reply all
Reply to author
Forward
0 new messages