Navigation Menu

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

String '0x0001' cannot be converted to int #2047

Open
haaspors opened this issue Jul 9, 2017 · 5 comments
Open

String '0x0001' cannot be converted to int #2047

haaspors opened this issue Jul 9, 2017 · 5 comments

Comments

@haaspors
Copy link
Contributor

haaspors commented Jul 9, 2017

I'm using get_define() and to_int() which gives this error.
Haven't looked deeply into meson regarding this, but should String.to_int() be able to parse hexadecimal and other number systems?

@jpakkane
Copy link
Member

What is the specific use case for this?

@hadess
Copy link

hadess commented Apr 14, 2018

@neilmcgovern
Copy link

A specific use case in this context of the GNOME bug is the setting of permissions in config when building a project. For example, if you:
config.set("DEFAULT_PERMISSIONS", 0700,"Default permissions for new files")
then config.h will output:
#define DEFAULT PERMISSIONS 700

@nirbheek
Copy link
Member

This issue is about str.to_int() knowing that "0x01" represents a hex in string form, and same for octal. The problem you're hitting is that the integer type in Meson does not support octal. We support hex (0xFF, etc), but not 0644, etc.

However, you do not really need this. As suggested on the GitLab issue, you can use strings.

@nirbheek
Copy link
Member

... however if we don't support octal we should not silently drop the leading 0. We should error out or at least give a warning.

gnomesysadmins pushed a commit to GNOME/gnome-control-center that referenced this issue Apr 17, 2018
meson defines `USER_DIR_MODE` with a raw octal value to be used as
the default permissions when creating the user's configuration
directory.

However, meson does not support raw octal values[0], so the define
misses the initial `0` value. Due to this, the directory is created
with wrong permissions.

This has been changed to use the octal value as a string in meson,
so the definition has the proper value.

Fixes #49

[0] mesonbuild/meson#2047
gnomesysadmins pushed a commit to GNOME/gnome-control-center that referenced this issue Apr 17, 2018
meson defines `USER_DIR_MODE` with a raw octal value to be used as
the default permissions when creating the user's configuration
directory.

However, meson does not support raw octal values[0], so the define
misses the initial `0` value. Due to this, the directory is created
with wrong permissions.

This has been changed to use the octal value as a string in meson,
so the definition has the proper value.

Fixes #49

[0] mesonbuild/meson#2047


(cherry picked from commit 37a6b94)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants