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?
Use this UINTPTR_MAX value to check build type.
The same program source can (and should be able to) be compiled in 64-bit computers, 32-bit computers, 36-bit computers, ...
So, just by looking at the source, if it is any good, you cannot tell how it will be compiled. If the source is not so good, it may be possible to guess what the programmer assumed would be used to compile it under.
My answer to you is:
There is a way to check the number of bits needed for a source file only for bad programs.
You should strive to make your programs work no matter on how many bits they will be compiled for.