As for the Vala language cross-platform to know the bitness of the system?
-
2Why do you want to know? XY problem? http://xyproblem.info/ – Jens Mühlenhoff Mar 12 '18 at 00:11
-
@JensMühlenhoff You will need to download the files you are using, depending on the bitness of the system. – Syabro Mar 12 '18 at 03:41
-
I see, that is one of the rare cases where it would be useful indeed. – Jens Mühlenhoff Mar 12 '18 at 09:21
2 Answers
sizeof(void*)
will be 8 for 64-bit systems and 4 for 32 bit systems. Also, 2 for 16 bit systems, but I don't even know that glib will work there.

- 16,623
- 1
- 43
- 62
The whole point of GLib is to avoid having to do platform specific code.
However according to you comment you want to do something like download platform specific packages.
First of all it would be better to use a system or user package manager to do that, since they already know how to achieve that (DRY principle).
If you absolutely must, you can also use tools like lsb-release -a
or the more general uname -a
(for the kernel and arch) or some other arguments to those tools.
You can invoke them with GLibs process spawning facilities.
See also:
How to determine whether a given Linux is 32 bit or 64 bit?
And a related problem is OS detection:
Is OS detection possible with GLib?
Also since Vala is a compiled language, you could use your favorite build system to pass something like -DPlatformx64
or -DPlatformx86
to the Vala compiler (see the above link on OS detection for an example on how to use the preprocessor in Vala code).

- 14,565
- 6
- 56
- 113