Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

determine CPU architecture in D

Tags:

header

d

I have a C header file (it's a part of some SDK) and there is a typedef which depends on system architecture (whether it is 32 or 64-bit), how do I transfer it to my D module? Thanks.

Edit: OK, that was too simple and I've already find a solution... If someone interested, it is:

version(X86) {
  typedef int your_type;
}
version(X86_64) {
  typedef long your_type;
}
like image 752
szx Avatar asked Jul 05 '10 23:07

szx


People also ask

How do I find my processor architecture in Linux?

The best way to quickly check your CPU architecture on Linux is by using the lscpu command. The utility is installed by default on all Linux distros.


1 Answers

version(X86)
{
    // 32-bit
}
else
version(X86_64)
{
    // 64-bit
}
else
{
    // none of the above
}

Source: http://digitalmars.com/d/2.0/version.html

like image 111
Vladimir Panteleev Avatar answered Sep 28 '22 02:09

Vladimir Panteleev