digitalmars.D - versions and 32 vs 64-bit code
- Nathan Coe (6/6) Dec 25 2011 Is there a way to change what is compiled in based on whether the -m32 o...
- Vladimir Panteleev (8/10) Dec 25 2011 The predefined version identifiers specify the *target*
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (14/20) Dec 26 2011 Use:
- Andrew Wiley (8/32) Dec 26 2011 r
- Andrej Mitrovic (4/13) Dec 26 2011 So why doesn't D_LP32 exist? If you already use "version(X86) else
- Xinok (3/17) Dec 26 2011 I agree, but I don't think D_LP32 would be correct since LP stands for
- =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= (4/18) Dec 26 2011 I don't think it's a big deal. You should write your code for D_LP64 in
Is there a way to change what is compiled in based on whether the -m32 or -m64 option is chosen? I can see that there are predefined versions (for X86 and X86_64 e.g.), but I don't know if this is based on the compile options, or the platform the compilation is being performed on. As an example, if I am compiling on a 64-bit intel machine, is the version X86 or X86_64 set by default? Thanks.
Dec 25 2011
On Monday, 26 December 2011 at 05:41:11 UTC, Nathan Coe wrote:As an example, if I am compiling on a 64-bit intel machine, is the version X86 or X86_64 set by default?The predefined version identifiers specify the *target* architecture. Note that the default target architecture matches the architecture of the compiler binary: the 64-bit DMD compiler has -m64 by default (use -m32 to override). http://dlang.org/version.html#PredefinedVersions lists predefined version identifiers.
Dec 25 2011
On 26-12-2011 06:41, Nathan Coe wrote:Is there a way to change what is compiled in based on whether the -m32 or -m64 option is chosen? I can see that there are predefined versions (for X86 and X86_64 e.g.), but I don't know if this is based on the compile options, or the platform the compilation is being performed on. As an example, if I am compiling on a 64-bit intel machine, is the version X86 or X86_64 set by default? Thanks.Use: version (D_LP64) { // 64-bit ... } else { // 32-bit ... } Always avoid using architecture identifiers to figure out bitness. There were plenty of cases of this in druntime and phobos which made portability very annoying (they are fixed now, though). - Alex
Dec 26 2011
On Mon, Dec 26, 2011 at 3:53 AM, Alex R=F8nne Petersen <xtzgzorex gmail.com> wrote:On 26-12-2011 06:41, Nathan Coe wrote:rIs there a way to change what is compiled in based on whether the -m32 o=or-m64 option is chosen? I can see that there are predefined versions (for X86 and X86_64 e.g.), but I don't know if this is based on the compile options, =ythe platform the compilation is being performed on. As an example, if I am compiling on a 64-bit intel machine, is the version X86 or X86_64 set by default? Thanks.Use: version (D_LP64) { =A0 =A0// 64-bit ... } else { =A0 =A0// 32-bit ... } Always avoid using architecture identifiers to figure out bitness. There were plenty of cases of this in druntime and phobos which made portabilit=very annoying (they are fixed now, though).+1 This makes things like, say, running code on ARM much much simpler. If you don't actually need X86, don't require it.
Dec 26 2011
On 12/26/11, Alex R=F8nne Petersen <xtzgzorex gmail.com> wrote:Use: version (D_LP64) { // 64-bit ... } else { // 32-bit ... }So why doesn't D_LP32 exist? If you already use "version(X86) else version(X86_64)" you're going to have to swap all of your code around if you start using D_LP64..
Dec 26 2011
On 12/26/2011 8:23 AM, Andrej Mitrovic wrote:On 12/26/11, Alex Rønne Petersen<xtzgzorex gmail.com> wrote:I agree, but I don't think D_LP32 would be correct since LP stands for "long pointer".Use: version (D_LP64) { // 64-bit ... } else { // 32-bit ... }So why doesn't D_LP32 exist? If you already use "version(X86) else version(X86_64)" you're going to have to swap all of your code around if you start using D_LP64..
Dec 26 2011
On 26-12-2011 14:23, Andrej Mitrovic wrote:On 12/26/11, Alex Rønne Petersen<xtzgzorex gmail.com> wrote:I don't think it's a big deal. You should write your code for D_LP64 in the first place anyway. - AlexUse: version (D_LP64) { // 64-bit ... } else { // 32-bit ... }So why doesn't D_LP32 exist? If you already use "version(X86) else version(X86_64)" you're going to have to swap all of your code around if you start using D_LP64..
Dec 26 2011