Standard C++ only generates native code for the architecture it runs on, so there’s no way to run on different architecture. The only way is to compile for proper architecture.
Of course a 32-bit application could run on a 64-bit operating system if it has some compatibility layer. This is the case of Windows and some Linux distributions. The opposite is not technically feasible even if someone wanted to do it, except for a complex emulation and the result will be horrible.
Just compiling for another architecture may not be enough. The code needs to be well written to work well on both, the problem may be there.
Technically it would be possible to have a feature like C# (non-native code), but nobody bothered to do it because it didn’t make much sense.
This application I am developing is divided into client and server, the client is made in C#. NET and the server in native C++ . In the case of the client part, in Visual Studio there is the Any CPU option, so I thought it might be possible to leave the multi-architecture c++ application.
– Hércules Moreira
In case I compile for 32 bits, theoretically a 64 bit machine could also run it, right?
– Hércules Moreira
It is possible yes. The 64bit architecture is an extension of the 32bit. However, if you are integrating with other software that in one machine is 32 bits and in the other is 64 bits, the memory accesses can be compromised.
– Rodrigo Guiotti