dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Function signature error

  1. #1
    Join Date
    Apr 2003
    Location
    kathmandu, nepal
    Posts
    1,570

    Function signature error

    Hello all,

    I have the following code:

    Code:
    class TiffStream {
    
    public:
        // ctor/dtor
        TiffStream();
        ~TiffStream();
    
    public:
        enum SeekDir {
    	    beg,
    	    cur,
    	    end,
        };
    
    public:
        // factory methods
        TIFF* makeFileStream(std::iostream* str);
        TIFF* makeFileStream(std::ifstream* str);
        TIFF* makeFileStream(std::ofstream* str);
    
    public:
        // tiff client methods
        static tsize_t read(thandle_t fd, tdata_t buf, tsize_t size);
        static tsize_t write(thandle_t fd, tdata_t buf, tsize_t size);
        static toff_t seek(thandle_t fd, toff_t offset, int origin);
        static toff_t size(thandle_t fd);
        static int close(thandle_t fd);
        static int map(thandle_t fd, tdata_t* phase, toff_t* psize);
        static void unmap(thandle_t fd, tdata_t base, tsize_t size);
    
        ..................
        ..................
    };
    Code:
    TIFF*
    TiffStream::makeFileStream(ifstream* str)
    {
        m_inStream = str;
        m_outStream = NULL;
        m_ioStream = NULL;
        m_streamLength = getSize(m_this);
    
        m_tif =  TIFFClientOpen(m_name, 
                               "r",
    			   m_this,
    			   read,
    			   write,
    			   seek,
    			   close,
    			   size,
    			   map,
    			   unmap);
        return m_tif;
    }
    
    TIFF*
    TiffStream::makeFileStream(ofstream* str)
    {
    	m_inStream = NULL;
            m_outStream = str;
    	m_ioStream = NULL;
    	m_streamLength = getSize(m_this);
    
    	m_tif =  TIFFClientOpen(m_name, 
                               "w",
    			   m_this,
    			   read,
    			   write,
    			   seek,
    			   close,
    			   size,
    			   map,
    			   unmap);
        return m_tif;
    }
    
    TIFF*
    TiffStream::makeFileStream(iostream* str)
    {
        m_inStream = NULL;
        m_outStream = NULL;
        m_ioStream = str;
        m_streamLength = getSize(m_this);
    
        m_tif =  TIFFClientOpen(m_name, 
    	                       "r+w",
    	                       m_this,
    			       read,
    			       write,
    			       seek,
    			       close,
    			       size,
    			       map,
    			       unmap);
        return m_tif;
    }
    The error generated is as below:

    Code:
    1>i:\de5.5_sdk_21_may_2008(2)\de5.5_sdk\deplugins\plugins\2d\tiffstream.cpp(45) : error C2664: 'TIFFClientOpen' : cannot convert parameter 10 from 'void (__cdecl *)(thandle_t,tdata_t,tsize_t)' to 'TIFFUnmapFileProc'
    1>        None of the functions with this name in scope match the target type
    1>i:\de5.5_sdk_21_may_2008(2)\de5.5_sdk\deplugins\plugins\2d\tiffstream.cpp(66) : error C2664: 'TIFFClientOpen' : cannot convert parameter 10 from 'void (__cdecl *)(thandle_t,tdata_t,tsize_t)' to 'TIFFUnmapFileProc'
    1>        None of the functions with this name in scope match the target type
    1>i:\de5.5_sdk_21_may_2008(2)\de5.5_sdk\deplugins\plugins\2d\tiffstream.cpp(87) : error C2664: 'TIFFClientOpen' : cannot convert parameter 10 from 'void (__cdecl *)(thandle_t,tdata_t,tsize_t)' to 'TIFFUnmapFileProc'
    1>        None of the functions with this name in scope match the target type
    1>Build log was saved at "file://I:\DE5.5_SDK_21_May_2008(2)\DE5.5_SDK\DE42\Temp\Win32\vc80\Debug\2d\BuildLog.htm"
    1>2d - 3 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
    Code:
    #if defined(__cplusplus)
    extern "C" {
    #endif
    typedef	void (*TIFFErrorHandler)(const char*, const char*, va_list);
    typedef	tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);
    typedef	toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
    typedef	int (*TIFFCloseProc)(thandle_t);
    typedef	toff_t (*TIFFSizeProc)(thandle_t);
    typedef	int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);
    typedef	void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);
    ................
    ................
    ................
    The following is the TIFFClientOpen function's signature
    Code:
    TIFF*
    TIFFClientOpen(
    	const char* name, const char* mode,
    	thandle_t clientdata,
    	TIFFReadWriteProc readproc,
    	TIFFReadWriteProc writeproc,
    	TIFFSeekProc seekproc,
    	TIFFCloseProc closeproc,
    	TIFFSizeProc sizeproc,
    	TIFFMapFileProc mapproc,
    	TIFFUnmapFileProc unmapproc
    )
    The error is generated for only the "unmap" function. Instead of a static class member function I used a free function. But still the error is there. Please help. I am stuck with this.
    Last edited by miteshpandey; May 28th, 2008 at 11:10 AM.
    If there is no love sun won't shine

  2. #2
    Join Date
    May 2006
    Location
    Dresden, Germany
    Posts
    458

    Re: Function signature error

    Hi,

    I would explicitly mark the function as "__cdecl".
    I'm not sure if this is the solution, but you can give it a try.

    __cdecl (like expected in the error message) is usually not the standard calling function of MS VC++ (but this depends on the projects options).

    In my experience this helped when giving call back functions...

    If this is the case it will work for static members as well as for "free" functions.

    With regards
    Programartist
    Ingo Bochmann

  3. #3
    Join Date
    May 2002
    Location
    Lindenhurst, NY
    Posts
    867

    Re: Function signature error

    You're passing a function pointer to this:

    Code:
    static void unmap(thandle_t fd, tdata_t base, tsize_t size);
    but the expected signature is:

    Code:
    typedef	void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);

  4. #4
    Join Date
    Apr 2003
    Location
    kathmandu, nepal
    Posts
    1,570

    Re: Function signature error

    Thanks a lot Martin O . Dear God how could I have missed that?
    If there is no love sun won't shine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)