Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format specifier warning in pdfrenderer.cpp #20

Closed
rmtheis opened this issue May 18, 2015 · 5 comments
Closed

Format specifier warning in pdfrenderer.cpp #20

rmtheis opened this issue May 18, 2015 · 5 comments
Labels

Comments

@rmtheis
Copy link
Contributor

rmtheis commented May 18, 2015

I get a format specifier warning when building for Android using clang and tess-two:

jni/com_googlecode_tesseract_android/src/api/pdfrenderer.cpp:537:28: warning: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
               "stream\n", len);
                           ^~~

I think it should be %zd or %zu instead of %ld, but I'm not sure if that works on Visual Studio too.

@zdenop
Copy link
Contributor

zdenop commented May 18, 2015

it seems that the z prefix isn't defined in MS Visual Studio size specification.

@jbreiden
Copy link
Contributor

I'm the author of this code. I'd prefer to keep using size_t for this number since PDF files can be really big (although, this code will break for other reasons once we get larger than 10 gigabytes). Not sure what to do here to make all platforms happy.

http://stackoverflow.com/questions/2524611/how-to-print-size-t-variable-portably

@rmtheis
Copy link
Contributor Author

rmtheis commented Jul 21, 2015

OK--since this warning isn't indicative of a larger problem, and there's no clear solution for muting this warning across the board, let's close this issue.

@rmtheis rmtheis closed this as completed Jul 21, 2015
@stweil
Copy link
Member

stweil commented Jul 21, 2015

That's not a solution. It's a bug, not a compiler warning which must be muted.

You will get a wrong results on little endian platforms when sizeof(long) != sizeof(size_t).
On big endian platforms the result is wrong when sizeof(long) > sizeof(size_t).

Adding a type cast would help: (long)len

Even better would be replacing "%ld" by "%lu" and using this: (unsigned long)len

@amitdo
Copy link
Collaborator

amitdo commented May 30, 2016

It seems that @stweil solved this with this commit:
997c4a6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants