Skip to content

Name collisions for functions without prefix #754

Open

Description

@KaruroChori

There are several functions in qjs which are too easy to collide as:

  • they are not static
  • they are not namespaced with a prefix.

There are two specific offenders I encountered, pstrcat & pstrcpy, both colliding with their equivalent implementations in tinycc. There are few more which have just too much of a generic name, like has_suffix.
All these "offenders" are declared in cutils.h and implemented in cutils.c.

My suggestion would be for these functions to be scoped with some prefix, as I don't think they are really meant to be used from outside qjs.

Activity

  1. saghul commented on Dec 14, 2024

    @saghul
    Contributor

    They are not zoomed in the API so their visibility should be hidden, how are you using them?

  2. chqrlie commented on Dec 14, 2024

    @chqrlie
    Collaborator

    I ran into the same issue for qemacs, for the same reason... as the original author of these functions that Fabrice collected in cutils.[hc] and used in different projects. We should just scope them with a js_ prefix using #define or changing the calls in the qjs source files (actually very few instances). Other offenders include strstart, rqsort, [ui]{32,64}toa{,_radix} and digits36, utf8_xxx handlers, dbuf_xxx API...

  3. KaruroChori commented on Dec 14, 2024

    @KaruroChori
    ContributorAuthor

    They are not zoomed in the API so their visibility should be hidden, how are you using them?

    Just statically linking qjs and tcc within the same project.

  4. saghul commented on Dec 14, 2024

    @saghul
    Contributor

    👍 would either of you mind sending a pr?

  5. chqrlie commented on Dec 14, 2024

    @chqrlie
    Collaborator

    👍 would either of you mind sending a pr?

    Will do! back in business :)

  6. KaruroChori commented on Dec 15, 2024

    @KaruroChori
    ContributorAuthor

    I already started changing some locally to make my project work

    void js__pstrcpy(char *buf, int buf_size, const char *str);
    char *js__pstrcat(char *buf, int buf_size, const char *s);
    int js__strstart(const char *str, const char *val, const char **ptr);
    int js__has_suffix(const char *str, const char *suffix);
    

    and pushed them in #755

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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