Is 64bit

Linux specific forum
danielheth
New User
New User
Posts: 9
Joined: Mon Dec 01, 2014 5:12 pm
Location: Arkansas
Contact:

Is 64bit

Post by danielheth »

I'm creating a cross platform application and thus compiling on Windows, Mac, Linux 32bit and Linux 64bit. The windows and mac version is compiled as 32bit... and the only reason to have a linux 64bit is so i don't have to force my users to install 32bit libraries on their linux 64bit machines. Now onto my question...

In order to differentiate between my apps when i call for the version, i'm using compiler flags:

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  vName = vName + "for Windows"
CompilerElseIf #PB_Compiler_OS = #PB_OS_Linux
  CompilerIf #PB_Processor_x64
    vName = vName + "for Linux 64bit"
  CompilerElse
    vName = vName + "for Linux 32bit"
  CompilerEndIf
CompilerElseIf #PB_Compiler_OS = #PB_OS_MacOS
  vName = vName + "for Mac"
CompilerEndIf
The problem is if i run my 32bit linux version on a system with a 64bit processor, it identifies as a 64bit... Is there a different flag or way to tell if my app is compiled as 32bit or 64bit at runtime?
danielheth
New User
New User
Posts: 9
Joined: Mon Dec 01, 2014 5:12 pm
Location: Arkansas
Contact:

Re: Is 64bit

Post by danielheth »

Found my answer in another thread...http://www.forums.purebasic.com/english ... 19&t=58314

Code: Select all

    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
      vName = vName + "for Windows"
    CompilerElseIf #PB_Compiler_OS = #PB_OS_Linux
      CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
        vName = vName + "for Linux 32bit"
      CompilerElse
        vName = vName + "for Linux 64bit"
      CompilerEndIf
    CompilerElseIf #PB_Compiler_OS = #PB_OS_MacOS
      vName = vName + "for Mac"
    CompilerEndIf
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Is 64bit

Post by luis »

danielheth wrote: The problem is if i run my 32bit linux version on a system with a 64bit processor, it identifies as a 64bit
To clarify the reason behind it:

#PB_Compiler_Processor is set to 2 on x86 and to 4 on x64.
#PB_Processor_x86 is always set to 2.
#PB_Processor_x64 is always set to 4.

#PB_Compiler_Processor is intended to be compared to #PB_Processor_x86 or #PB_Processor_x64.

You wrote

Code: Select all

  CompilerIf #PB_Processor_x64
    vName = vName + "for Linux 64bit"
  CompilerElse
    vName = vName + "for Linux 32bit"
  CompilerEndIf


which in turn means

Code: Select all

   CompilerIf 4
    vName = vName + "for Linux 64bit"
  CompilerElse
    vName = vName + "for Linux 32bit"
  CompilerEndIf
4 is #True, so it was compiling the first code branch independently from the architecture you compiled the program on.


But for some reason you used the right approach for the OS instead ... :)

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Windows
"Have you tried turning it off and on again ?"
Post Reply