Reputation: 10266
I'm writing a C harness to call a C++ API. I have the following code:
Boxa *tess_get_text_lines(tess_api_t *api, const bool raw_image,
const int raw_padding, Pixa** pixa, int **blockids,
int **paraids)
{
return api->tess_api->GetTextlines(raw_image, raw_padding, pixa, blockids,
paraids);
}
I'm getting the following G++ error:
$ ./build_so.sh
tesseract.cpp: In function ‘Boxa* tess_get_text_lines(tess_api_t*, bool, int, Pixa**, int**, int**)’:
tesseract.cpp:172:47: error: no matching function for call to ‘tesseract::TessBaseAPI::GetTextlines(const bool&, const int&, Pixa**&, int**&, int**&)’
tesseract.cpp:172:47: note: candidate is:
In file included from tesseract.cpp:3:0:
/usr/include/tesseract/baseapi.h:376:9: note: Boxa* tesseract::TessBaseAPI::GetTextlines(Pixa**, int**)
/usr/include/tesseract/baseapi.h:376:9: note: candidate expects 2 arguments, 5 provided
It's not matching my call to the correct overload. For reference, the following are the available overloads for the method being called:
Boxa* GetTextlines(const bool raw_image, const int raw_padding,
Pixa** pixa, int** blockids, int** paraids);
Boxa* GetTextlines(Pixa** pixa, int** blockids);
Why is my call being translated to "GetTextlines(const bool&, const int&, Pixa*&, int*&, int**&)" (with all of the by-ref'ing)?
Thanks.
Upvotes: 0
Views: 89
Reputation: 10266
Actually it turns out that though Tesseract has been around for eighteen years, the trunk version that I've been using has, against all odds, been given a number of additional overloads since the latest published, downloadable version (3.02.02) from earlier this year.
So, the answer to the reported problem is that, as @templatetypedef indicated, most likely that GCC is just decorating the variables with ampersands for the benefit of the error-message. The answer to the effective problem that I was having is simply that I'm not looking at an in-sync copy of the API headers.
Upvotes: 0
Reputation: 373022
The compiler isn't introducing references automatically. Instead, it's noting that the arguments you're providing are lvalues and attempting to find an overload that would work if provided reference types. (Notice that the types provided are information about the types you're passing into the function rather than the types actually in the signature of the function.)
That said, the error does give you the information you need to solve the problem. Notice that the first type it's saying is const bool
, but the function you're trying to call takes a tess_api_t*
. I think you may need to change the way you're calling the function.
Hope this helps!
Upvotes: 1