- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello experts
BUG in NIOS2 C++ compiler Declaration below, is template Class which valid (we where check it at other compilers ) ///////// IT IS VALID CODE BUT COMPILER TROW ERROR!!!! //////// look to the end of string which begin with FlatScreen .... template <class T> class FlatScreen:public Screen { protected: int32 line_width; T* mData; virtual void close(void); //---------------------------------------------------------------------------------------------LOOK HERE FlatScreen(int w,int h,int bpp,size_t lw,T* ptr):Screen(w,h,bpp),mData(ptr),line_width(lw?lw:w*sizeof(T)) //line_width(lw?lw:w*sizeof(T) - MUST BE ASSIGNED { assert(mData); } public: T* GetPtr(void) { return mData; } virtual ~FlatScreen(void); virtual void _PutPixel(int x,int y,uint32 color); virtual uint32 _GetPixel(int x,int y); virtual void _vline(int x,int y,int h,uint32 color); virtual void _line(int x0,int y0,int x1,int y1,uint32 color); virtual void _outchar(int x,int y,uint ch,uint32 color,const cRect* rect); virtual void _PutImage(int x,int y,const tPicture* image,const cRect* rect); virtual void _GetImage(int x,int y,int w,int h,tPicture* image,const cRect* rect); virtual void _BitBlt(int x,int y,int w,int h,const void* image,const cRect* rect); }; To solve that problem we replace assigning of values to constuctor body like shown below : template <class T> class FlatScreen:public Screen { protected: int32 line_width; T* mData; virtual void close(void); //----------------------- !!!!!!!!!!!!!!!!!!!!!!!!!!!! FlatScreen(int w,int h,int bpp,size_t lw,T* ptr):Screen(w,h,bpp),mData(ptr) { assert(mData); line_width=lw?lw:w*sizeof(T); // Replased from constructor because nios2-elf-gcc compiler have a BUG!!! } public: T* GetPtr(void) { return mData; } virtual ~FlatScreen(void); virtual void _PutPixel(int x,int y,uint32 color); virtual uint32 _GetPixel(int x,int y); virtual void _vline(int x,int y,int h,uint32 color); virtual void _line(int x0,int y0,int x1,int y1,uint32 color); virtual void _outchar(int x,int y,uint ch,uint32 color,const cRect* rect); virtual void _PutImage(int x,int y,const tPicture* image,const cRect* rect); virtual void _GetImage(int x,int y,int w,int h,tPicture* image,const cRect* rect); virtual void _BitBlt(int x,int y,int w,int h,const void* image,const cRect* rect); }; I'ts fundamental BUG - and i guess it not last bug of C++ compiler .... http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif So is it possible to fix BUG's of that type in NEXT release ?Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you please post both the error message you are getting from the compiler, and if possible a reduced test case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I guess the reason you want the initializer version of your code to work is so you can declare line_width as const int32 instead of just int32.
Do either of the following work? FlatScreen(int w,int h,int bpp,size_t lw,T* ptr):Screen(w,h,bpp),mData(ptr),line_width(lw?lw:size_t(w)*sizeof(T)) FlatScreen(int w,int h,int bpp,size_t lw,T* ptr):Screen(w,h,bpp),mData(ptr),line_width(size_t(lw?lw:w*sizeof(T))) And yes, please show us the actual error message.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page