Menu

#364 Invalid typedef in GString.h breaks C++ builds with modern compilers

djview
closed
nobody
None
5
2025-09-10
2025-07-09
Janusz
No

[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).

Related

Bugs: #364

Discussion

  • Leon Bottou

    Leon Bottou - 2025-07-09

    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>

    • Leon

    if HAVE_STDINT_H

    include <stdint.h></stdint.h>

    elif HAVE_INTTYPES_H

    include <inttypes.h></inttypes.h>

    else

    ifdef _WIN32

    On Jul 9, 2025, at 10:01 AM, Janusz jsbien@users.sourceforge.net wrote:

    [bugs:#364] https://sourceforge.net/p/djvu/bugs/364/ Invalid typedef in GString.h breaks C++ builds with modern compilers

    Status: open
    Group: djview
    Created: Wed Jul 09, 2025 02:01 PM UTC by Janusz
    Last Updated: Wed Jul 09, 2025 02:01 PM UTC
    Owner: nobody

    [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).

    Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/djvu/bugs/364/

    To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

     

    Related

    Bugs: #364

  • Janusz

    Janusz - 2025-07-09

    Since 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.

     
  • Leon Bottou

    Leon Bottou - 2025-08-04
    • status: open --> closed
     
  • Leon Bottou

    Leon Bottou - 2025-08-04

    Fixed

     
  • Dr Bill C Riemers

    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.

     
  • Dr Bill C Riemers

    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.

     

Log in to post a comment.