Serial port?
Are those the small blue ports your monitor is connected to?
No they are the ports that are being replaced by USB, most computers used to have 2 of them but today normally they only have 1. Generally they use the RS232 protocol and can be used for serial communication to a large number of devices.
saranjegan presumably you aren't actually proposing to run the same image on both machines, you are just trying to build a portable program? You should find some compiler symbols that enable you to distinguish which platform you are compiling for.
For instance the MSVC compiler defines the symbol _MSC_VER to its version number, presence of this symbol indicates use of the MSVC compiler and therefore a Windows platform as the target.
Check you compiler documentation for the symbols it defines.