[opensuse] Test Compiler - 64-bit or 32-bit
Hello there, I am hoping that some one can point me in the right direction here. I have a program that compiles under both 32-bit and 64-bit architecture. What I want to be able to do is determine which way the program was compiled either 32-bit or 64-bit, similar to 'file' command, but called from within the executable itself. I use the system call 'uname' to determine the machine architecture that the program is executing on; does anyone know of a similar call to determine which compilation. Thanks Peter -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thu, Oct 22, 2009 at 09:27:27AM -0400, Peter Bloomfield wrote:
Hello there,
I am hoping that some one can point me in the right direction here. I have a program that compiles under both 32-bit and 64-bit architecture. What I want to be able to do is determine which way the program was compiled either 32-bit or 64-bit, similar to 'file' command, but called from within the executable itself. I use the system call 'uname' to determine the machine architecture that the program is executing on; does anyone know of a similar call to determine which compilation.
What exactly do you want to know and why? Your program should not care at all if it is 32 or 64bit, but use sizeof() for data types and similar, and for storing data on disk a platform transparent dataformat. Ciao, Marcus -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 22 October 2009, you wrote:
On Thu, Oct 22, 2009 at 09:27:27AM -0400, Peter Bloomfield wrote:
Hello there,
I am hoping that some one can point me in the right direction here. I have a program that compiles under both 32-bit and 64-bit architecture. What I want to be able to do is determine which way the program was compiled either 32-bit or 64-bit, similar to 'file' command, but called from within the executable itself. I use the system call 'uname' to determine the machine architecture that the program is executing on; does anyone know of a similar call to determine which compilation.
What exactly do you want to know and why?
Your program should not care at all if it is 32 or 64bit, but use sizeof() for data types and similar, and for storing data on disk a platform transparent dataformat.
Ciao, Marcus The sizeof() will do it thanks. The reason is that I want to catch the 32-bit version executing on a 64-bit architecture. Peter
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 22/10/09 10:40, Peter Bloomfield wrote:
The reason is that I want to catch the 32-bit version executing on a 64-bit architecture.
Huh ? why ? Your userspace program shoulnt care about this.. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 22/10/09 10:27, Peter Bloomfield wrote:
I have a program that compiles under both 32-bit and 64-bit architecture.
Ok, but if it compiles it does not mean it works. What I want to be
able to do is determine which way the program was compiled either 32-bit or 64-bit, similar to 'file' command, but called from within the executable itself.
Why you need such a thing ? please elaborate better, It is almost certain that you are asking the wrong question. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 22 October 2009, Cristian Rodríguez wrote:
On 22/10/09 10:27, Peter Bloomfield wrote:
I have a program that compiles under both 32-bit and 64-bit architecture.
Ok, but if it compiles it does not mean it works.
What I want to be
able to do is determine which way the program was compiled either 32-bit or 64-bit, similar to 'file' command, but called from within the executable itself.
Why you need such a thing ? please elaborate better, It is almost certain that you are asking the wrong question. My question is correct. The problem is the 64-bit compiled version of the executable results in severe image artefacts after reconstruction; I know that this is not the case with the 32-bit compiled version. If I forget this sometime in the future, then I want the program to stop execution, flag an error, and I can then go back to my journal to check why I did it this way. You could ask why is this like this, well in that respect my hands are tied. Peter
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 22 October 2009 18:58:59 Peter Bloomfield wrote:
My question is correct. The problem is the 64-bit compiled version of the executable results in severe image artefacts after reconstruction; I know that this is not the case with the 32-bit compiled version. If I forget this sometime in the future, then I want the program to stop execution, flag an error, and I can then go back to my journal to check why I did it this way.
why not do it at compile time?
If you only care about x86-64, do:
#if defined __x86_64__
# error "Compiling on 64-bit x86-64 not supported."
#endif
If you care about other 64-bit machines, do:
#include
On Friday 23 October 2009, Andreas Jaeger wrote:
On Thursday 22 October 2009 18:58:59 Peter Bloomfield wrote:
My question is correct. The problem is the 64-bit compiled version of the executable results in severe image artefacts after reconstruction; I know that this is not the case with the 32-bit compiled version. If I forget this sometime in the future, then I want the program to stop execution, flag an error, and I can then go back to my journal to check why I did it this way.
why not do it at compile time?
If you only care about x86-64, do:
#if defined __x86_64__ # error "Compiling on 64-bit x86-64 not supported." #endif
If you care about other 64-bit machines, do: #include
#if __WORDSIZE == 64 # error "..." #endif that way you'll never get a 64-bit object at all ;)
I would prefer to fix the image code instead to properly work with both 32- bit and 64-bit wordsize, That is my preference, but some of it is out of my hands.
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (4)
-
Andreas Jaeger
-
Cristian Rodríguez
-
Marcus Meissner
-
Peter Bloomfield