1

As for the Vala language cross-platform to know the bitness of the system?

Syabro
  • 65
  • 7

2 Answers2

2

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.

nemequ
  • 16,623
  • 1
  • 43
  • 62
0

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).

Jens Mühlenhoff
  • 14,565
  • 6
  • 56
  • 113