[Prepared by AskTheCode chatbot]
In DjVuLibre's GString.h, line 140 contains an invalid typedef:
typedef unsigned short uint16_t // verify
This is not valid C++ because it lacks a terminating semicolon, and the comment doesn't prevent the compiler from interpreting this as an incomplete statement. It results in a hard error with modern C++ compilers (e.g., GCC 11+):
error: expected initializer before ‘typedef’
This error occurs when compiling DjVuLibre directly (e.g., as vendored source) without the system's <stdint.h> already included.</stdint.h>
Please fix this by changing the line to:
typedef unsigned short uint16_t; // verify
or, better yet, replace the entire block with proper detection of <stdint.h> support.</stdint.h>
This bug is hard to reproduce unless one disables standard header includes or uses DjVuLibre sources directly in another project (e.g., embedding into other C++ tools).
Yes.
But this line is only activated when neither HAVE_STDINT_H, HAVE_INTTYPES_H, not _WIN32 are defined.
These days, all systems have <stdint.h> and C++ specifies <cstdint> (which would have been so much simpler if these things existed when djvulibre was written.). So I am curious about your compilation setup.</cstdint></stdint.h>
if HAVE_STDINT_H
include <stdint.h></stdint.h>
elif HAVE_INTTYPES_H
include <inttypes.h></inttypes.h>
else
ifdef _WIN32
Related
Bugs:
#364Since several days AskTheCode is unable to compile a simple program, prepared by itself, namely has_composite_shapes.cpp.
The repository is now quite a mess after chaotic experiments: https://github.com/jsbien/labelshapes.
FYI, this is the link to the chat https://chatgpt.com/share/686e7fc0-0f14-800d-985b-dee2719899ab; the last advice also doesn't work.
Fixed
For future reference, I had a very similar problem on my Mac for a bit new code I wrote on ARM I was trying to compile on my Mac. It turns out most of those modern C++ definitions are not in default include file set. My solution was just to install G++, and and the instructions for doing so to my README.md file, rather than to make my code explicitly typedef values like this.
In this case though, I verified the presense of the respective header files and typedef. So it likely a cmake/automake problem. Which I'm sure you already found.