Is it possible for one compiler to compile C and C++ for Windows, Linux and Mac OS's and their corresponding different CPU's?
Four answers:
bakegoodz
2007-02-10 00:34:07 UTC
I'll answer with a different slant then the other answers. You can do what is called cross compiling. With gcc you can compile for one cpu architecture on another. Also you can cross compile for other operating system too. There is a compiler based on gcc that will compile console apps for Win32 on Linux or Linux apps on Windows called MinGW. To do GUI apps the software has to be engineered for portability from the beginning using cross platform API such as WxWindows, QT, or GTK.
Neil M
2007-02-08 15:49:49 UTC
Well, gcc can compile for all of these with different backends.
Although, this might be a trick question, since Windows, Linux and Mac OSX can all run on Intel CPUs!
cottom
2016-12-04 03:13:57 UTC
As lengthy your code makes use of ANSI C++, you do not decide on to be stricken about portability; regardless of the indisputable fact that, it really is difficult even at the same time as utilising ANSI C++! case in element the function "gadget" less than the c header report stdlib parses an OS shell command to execute by skill of C++; at the same time as typing gadget("cls"); less than residing house windows it is going to sparkling the dos demonstrate screen, yet "cls" would not exist in Linux; extremely, "sparkling" will sparkling the terminal demonstrate screen less than Linux! C++ would not care and it parses the string parameter handed to the gadget function; syntax-smart, it accepts any string interior it, yet at the same time as it includes execution, you gained't get the outcome you anticipated because there are particular OS issues. Any way, Borland released 2 years in the past "Borland C++ BuilderX" it truly is a flow-plattform C++ Compiler; you chosen the objective operating gadget on your undertaking and the compiler will generate a properly proper code for that objective OS; that is a wounderful launch, yet after the launch Borland Studio 2006 it really is been bumped off! possibly now contained in the iteration "CodeGear" this help is again; i'm not particular, so verify it out, yet i'm extremely particular you'll discover what you opt on less than "Borland C++ BuilderX" regardless of the reality that it really is now tricky to discover for get carry of.
alakit013
2007-02-08 15:49:10 UTC
You can use, say, GCC for Windows, *NIX and MAC OSX (that also can be said UNIX clone). But in any case you will need to recompile your code for different environments separately even if your code is fully portable: different, incompatible libraries...
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.