How to determine if running on a 32 or 64 bits kernel ?



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" ...
.


Quantcast