Well, I’m starting at computer programming like c++ and c. I have a strong question about processor architetures that will able me to understand better where my code will run.
So, let’s say I compile a c++ program. At this moment, it compiled to a assembly low level code. This code has the processor instructions to do my code. As every processor has a different set of instructions, I wanted to know where my code will run.
Like, I compile my programs at code blocks. How do I know if I’m compiling it for a 32-bits or 64-bits computer? Can I change it? What is the difference between two 32-bits processor, one is a i5, the other a pentium 4? (will my code run in the two processors?)
thanks 🙂
You have to tell the compiler when you build your program. It probably has some defaults – check its documentation.
Maybe, it depends on your compiler. If it has the necessary options, then yes.
clang, for example, has a-archflag.If both implement the same instruction set, then they’re practically equivalent for purposes of compiling your software. It’s possible that very machine-specific optimizations might work better on one or the other, though.
In the case of the example you gave, probably yes.