Skip to content

Improve Glk C++ compatibility #2

@cspiegel

Description

@cspiegel

I've run into a couple issues while working with Glk in C++.

  1. The Glk ABI is C (no mangled names), but the provided glk.h header (at https://www.eblong.com/zarf/glk/glk.h) provides C++ (mangled) names when used with a C++ compiler. Client code can, of course, wrap the include in extern "C", but it would be very convenient if instead glk.h itself had such a declaration, wrapped in #ifdef __cplusplus.
  2. There are many functions which accept a char * parameter where const char * would be preferred. This is actually not strictly a C++ issue, given that it's reasonable in C to use const char * for safety, and then be forced to cast to char *, but it's more pronounced in C++ where string literals have type "array of const char" instead of "array of char".

I request that the offical Glk header file be updated to be more friendly to C++. These changes shouldn't affect existing programs which make use of Glk, except perhaps if a pointer to one of the char *-accepting functions is being stored... but that's probably unlikely, and would be easy to change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions