Re: How to determine if running on a 32 or 64 bits kernel ?
- From: Bernhard Agthe <dark2star@xxxxxxx>
- Date: Thu, 14 Feb 2008 15:42:10 +0100
laurent.charmet@xxxxxxxxx wrote:
I'm looking for an API or whatever to determine if kernel/os is 32 or
64 bits. It must be dynamic, because my binary can be compiled on a
machine and run on another. So sizeof(void*) is useless since it give
4 if my program was compiled on a 32 bits linux, even if I run it on a
64 bits.
I do not find information in /proc nor in sysconf, sysinfo etc ...
The only solution, but very crappy is to make a popen of "file -b /usr/
bin/file" and search for string "64" ...
uname -a
sizeof (void*) will give you the size of a pointer to nothing ;-)
A program compiled on 32 bit and linked with 32 bit libs will always be
32 bit... Sizeof is usually evaluated during compile time.
.
- Follow-Ups:
- Re: How to determine if running on a 32 or 64 bits kernel ?
- From: laurent . charmet
- Re: How to determine if running on a 32 or 64 bits kernel ?
- References:
- How to determine if running on a 32 or 64 bits kernel ?
- From: laurent . charmet
- How to determine if running on a 32 or 64 bits kernel ?
- Prev by Date: Re: How to determine if running on a 32 or 64 bits kernel ?
- Next by Date: Re: How to determine if running on a 32 or 64 bits kernel ?
- Previous by thread: How to determine if running on a 32 or 64 bits kernel ?
- Next by thread: Re: How to determine if running on a 32 or 64 bits kernel ?
- Index(es):
Relevant Pages
|