Search code examples
c++opencvwrappershared-ptr

Error "field has incomplete type"


I'm trying to write IplImage wrapper.

Here is my code:

class DrawingDetector
{
public:
    typedef boost::shared_ptr<IplImage> ipl_image_ptr_t;

    DrawingDetector(){}
    DrawingDetector::DrawingDetector(IplImage* img) : m_image(img, ipl_deleter){}

private:

    static void ipl_deleter( IplImage* ipl_img )
    {
        if( ipl_img )
        {
            cvReleaseImage( &ipl_img );
        }
    }

    ipl_image_ptr_t m_image; // compiler error "field ‘m_image’ has incomplete type"

};

I've got the following compling error "field ‘m_image’ has incomplete type". My compiler is gcc 4.4.

Why I can't create an empty shared_ptr?


Solution

  • Since the field has type boost::shared_ptr<IplImage>, it seems you haven't included boost/shared_ptr.hpp and/or the header defining IplImage. For IplImage it could be sufficient to provide only a forward declaration.