is there a C macro or some kind of way that i can check if my c program was compiled as 64bit or 32bit at compile time in C?
Compiler: GCC Operating systems that i need to do the checks on: Unix/Linux
Also how could i check when running my program if the OS is capable of 64bit?
To check this, we have to type this command. gcc –v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu ........... ........... ...........
Just type the following command on Linux terminal. Command: gcc -v Output Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper Target: x86_64-linux-gnu ...................... ......................
After you convert your 32-bit driver source code to use the new data types, you can use the 64-bit compiler to identify any type-related problems that you initially missed. The first time you compile this code for 64-bit Windows, the compiler might generate many pointer-truncation or type-mismatch warnings.
Firstly, we need GCC, the GNU compiler collection. Secondly, binutils is a set of tools for creating and managing binary programs, including a linker and assembler. In addition, we have to install Make – the build automation tool – and the C standard library glibc.
Since you tagged this "gcc", try
#if __x86_64__ /* 64-bit */ #endif
Here is the correct and portable test which does not assume x86 or anything else:
#include <stdint.h> #if UINTPTR_MAX == 0xffffffff /* 32-bit */ #elif UINTPTR_MAX == 0xffffffffffffffff /* 64-bit */ #else /* wtf */ #endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With