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

NK_STRTOD has extra const qualifier that blocks using standard library #700

Open
Xeverous opened this issue Sep 23, 2024 · 0 comments
Open

Comments

@Xeverous
Copy link
Contributor

Nuklear's code:

NK_API float
nk_strtof(const char *str, const char **endptr)
{
    float float_value;
    double double_value;
    double_value = NK_STRTOD(str, endptr);
    float_value = (float)double_value;
    return float_value;
}

The problem - standard library is incompatible:

// C89
double strtod(const char *restrict str, char **restrict str_end);
// C++ (any version)
double strtod(const char* str, char** str_end);

If I #define NK_STRTOD strtod then I'm getting the following error:

[...]/Nuklear/nuklear.h: In function ‘float nk_strtof(const char*, const char**)’:
[...]/Nuklear/nuklear.h:6841:35: error: invalid conversion from ‘const char**’ to ‘char**’ [-fpermissive]
 6841 |     double_value = NK_STRTOD(str, endptr);
      |                                   ^~~~~~
      |                                   |
      |                                   const char**
/usr/include/stdlib.h:118:27: note:   initializing argument 2 of ‘double strtod(const char*, char**)’
  118 |         char **__restrict __endptr)
      |         ~~~~~~~~~~~~~~~~~~^~~~~~~~

Can you change the implementation so that it supports the standard library (without const)?

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

No branches or pull requests

1 participant