Error: invalid user-defined conversion from WrappedImage to PFFINALRELEASE (C++)

I reproduce the exemple in the tutorial of polimago(cookies) but without cvbquick only with the terminal so without a window. But i have a Strange error when i compile and if i use a compile option to ignore this error i can’t load an image . So if someone have an idea to help me thanks.

the error message:

[build] [1/2  50% :: 5.126] Building CXX object CMakeFiles/classeurfinal.dir/main.cpp.obj
[build] FAILED: CMakeFiles/classeurfinal.dir/main.cpp.obj 
[build] C:\msys64\mingw32\bin\g++.exe   -isystem "C:/Program Files (x86)/STEMMER IMAGING/Common Vision Blox/Lib/C" -g -MD -MT CMakeFiles/classeurfinal.dir/main.cpp.obj -MF CMakeFiles\classeurfinal.dir\main.cpp.obj.d -o CMakeFiles/classeurfinal.dir/main.cpp.obj -c ../main.cpp
[build] In file included from C:/Program Files (x86)/STEMMER IMAGING/Common Vision Blox/Lib/C/cvb/_decl/decl_vpat.hpp:6,
[build]                  from C:/Program Files (x86)/STEMMER IMAGING/Common Vision Blox/Lib/C/cvb/image.hpp:3,
[build]                  from ../main.hpp:5,
[build]                  from ../main.cpp:1:
[build] C:/Program Files (x86)/STEMMER IMAGING/Common Vision Blox/Lib/C/cvb/_cexports/c_img.h: In instantiation of 'Cvb::V_1_4::CExports::cvbres_t Cvb::V_1_4::CExports::__CreateImageFromPointer(ARGS&& ...) [with ARGS = {void*&, unsigned int, long int, long int, long int, long int, int, int, int, long int*, Cvb::V_1_4::WrappedImage::Create(void*, int, int, int, int, Cvb::V_1_4::DataType, int, int, int, int*)::<lambda(void*&)>::<lambda(void*, void*)>, std::nullptr_t, void*&}; Cvb::V_1_4::CExports::cvbres_t = long int]':
[build] C:/Program Files (x86)/STEMMER IMAGING/Common Vision Blox/Lib/C/cvb/_decl/decl_wrapped_image.hpp:140:16:   required from here
[build] C:/Program Files (x86)/STEMMER IMAGING/Common Vision Blox/Lib/C/cvb/_cexports/c_img.h:366:1: error: invalid user-defined conversion from 'Cvb::V_1_4::WrappedImage::Create(void*, int, int, int, int, Cvb::V_1_4::DataType, int, int, int, int*)::<lambda(void*&)>::<lambda(void*, void*)>' to 'Cvb::V_1_4::CExports::PFFINALRELEASE' {aka 'void (__attribute__((stdcall)) *)(void*, void*)'} [-fpermissive]
[build]   366 | CVB_DEF_CAPI_X(cvbres_t, CreateImageFromPointer, (void * pImageMem, std::size_t MemSize, cvbdim_t Width, cvbdim_t Height, cvbdim_t NumPlanes, cvbdatatype_t DataType, std::intptr_t PitchX, std::intptr_t PitchY, std::intptr_t PitchPlane, cvbval_t PlaneOrder[], PFFINALRELEASE ReleaseCallback, void * pUserData, IMG & ImgOut))
[build]       | ^~~~~~~~~~~~~~
[build] C:/Program Files (x86)/STEMMER IMAGING/Common Vision Blox/Lib/C/cvb/_decl/decl_wrapped_image.hpp:140:16: note: candidate is: 'Cvb::V_1_4::WrappedImage::Create(void*, int, int, int, int, Cvb::V_1_4::DataType, int, int, int, int*)::<lambda(void*&)>::<lambda(void*, void*)>::operator void (*)(void*, void*)() const' <near match>
[build]   140 |         return CVB_CALL_CAPI(CreateImageFromPointer(buffer,
[build]       |                ^~~~~~~~~~~~~
[build] C:/Program Files (x86)/STEMMER IMAGING/Common Vision Blox/Lib/C/cvb/_decl/decl_wrapped_image.hpp:140:16: note:   no known conversion from 'void (*)(void*, void*)' to 'Cvb::V_1_4::CExports::PFFINALRELEASE' {aka 'void (__attribute__((stdcall)) *)(void*, void*)'}
[build] C:/Program Files (x86)/STEMMER IMAGING/Common Vision Blox/Lib/C/cvb/_cexports/c_img.h:366:1: note:   initializing argument 11 of 'Cvb::V_1_4::CExports::cvbres_t Cvb::V_1_4::CExports::CreateImageFromPointer(void*, std::size_t, Cvb::V_1_4::CExports::cvbdim_t, Cvb::V_1_4::CExports::cvbdim_t, Cvb::V_1_4::CExports::cvbdim_t, Cvb::V_1_4::CExports::cvbdatatype_t, intptr_t, intptr_t, intptr_t, Cvb::V_1_4::CExports::cvbval_t*, Cvb::V_1_4::CExports::PFFINALRELEASE, void*, void*&)'
[build]   366 | CVB_DEF_CAPI_X(cvbres_t, CreateImageFromPointer, (void * pImageMem, std::size_t MemSize, cvbdim_t Width, cvbdim_t Height, cvbdim_t NumPlanes, cvbdatatype_t DataType, std::intptr_t PitchX, std::intptr_t PitchY, std::intptr_t PitchPlane, cvbval_t PlaneOrder[], PFFINALRELEASE ReleaseCallback, void * pUserData, IMG & ImgOut))
[build]       | ^~~~~~~~~~~~~~
[build] ninja: build stopped: subcommand failed.
[build] La build s'est achevée avec le code de sortie 1

It seems the image is converted improperly. Could you please share the code? Also I would recommend using cmake.

1 Like

i use cmake and with the option fpermissive it work.but thank you for your help

Hi @enzo,

please be aware, that we do not support mingw.
Anyway you probably run into a special issue here as using a lamda as C function pointer is not well defined, especially with calling conventions. On our supported platforms and compilers it works.

However, here the complain/error seems valid. If it works ignoring it you may continue this way.

As we’re talking about the release callback here, the effect will only show at runtime (once the image goes out of scope and :cvb: invokes the lambda). So I recommend to test that bit early on…