CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012
    Posts
    2

    Question issue with a 2 libraries

    I have a MS VS 2008 C++ project that was running with "common langage runtime support" as /clrure without problems.
    I had to change it to /clr in order to use another library (GDAL), but now my other library (libcsv) is having problems

    Error 179 error C2664: 'csv_parse' : cannot convert parameter 4 from
    'void (__clrcall *)(void *,size_t,void *)' to
    'void (__cdecl *)(void *,size_t,void *)'

    Can I do something about it? (I can modify the code as I directly use the .cpp and .h from the libcsv)

    It is definatly the line when I use the function csv_parse from the libcsv library that gets me this error because when I comment it I can compile and run my code fine.

    The call to the csv_parse in FileConvert.cpp is as follow:
    Code:
    csv_parse(&parser, buf, bytes_read, concatstr, appendline, line);
    parameter 4 being this function:
    Code:
    void FileConvert::concatstr(void *_parsed, size_t bytes_read, void *_line)
    {
    	const char *parsed = (const char*)_parsed;
    	char *line = (char*)_line;
    	strncat(line, parsed, bytes_read);
    	if(bytes_read > 0)
    	{
    		i++;
    		strcat(line, " ");
    	}
    }
    Any help would be greatly appreciated. Spent a day reading about compilation and how to attach libraries in VS but I am kind of stuck right now...
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: issue with a 2 libraries

    You're apparently trying to pass a managed callback function to an (unmanaged) library function that in fact expects an unmanaged callback. As the callback function concatstr() references nothing but the parameters it gets passed and two C standard library functions, turning it from the managed class member function it is now into an unmanaged free function should work as a quick and dirty fix.

    In order to do that, remove the concatstr() prototype from the FileConvert class body and the FileConvert:: from the concatstr() function header. Then wrap up the function definition between #pragma managed(push, off) and #pragma managed(pop) directives. You may also need to add a prototype for the callback function or move its definition around in case it gets referenced before it is defined.

    HTH
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Mar 2012
    Posts
    2

    Re: issue with a 2 libraries

    Thanks a lot!

    I can now use my library =D ! I didn't do pragma definitions and decided to simply remove this class altogether because the function in question were more of a library type than an object anyway.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured