Is it possible to compile C / C ++ from Windows / Linux for Macs?

0

In a hypothetical environment where I do not have the system nor how to emulate, would it be possible to compile an application in C ++? (properly compatible)

I have already found some interesting cross-compilers , but they only manage to generate applications between the various distributions of linux, android and for windows.

    
asked by anonymous 05.07.2017 / 16:47

1 answer

0

Yes, it is possible. In fact, C ++ compilers by themselves always generate cross-platform code. What makes the code incompatible is when the programmer uses some library or command that is not available on another platform.

For example, if your code uses WinAPI it obviously will not run out of Windows, this is not the compiler's fault, it's because WinAPI only exists in Windows.

Another thing, if you write a system("cls"); your code will not run outside of Windows, because cls is a batch command to clear the cmd.exe window, and this obviously only exists in Windows. (The equivalent on Linux would be clear )

In short: Who makes C ++ code depend on platform is not the compiler, but the programmer.

    
05.11.2018 / 13:55