Reputation: 883
I have an subject at school where we code in C/C++ under Linux. We mostly do server/client apps using threads, semaphores, processes (fork(), pipes() etc.), IPCs. I have a MacBook and I don't really want to force it to run Ubuntu (which we use at school), so I wanna ask can I develop on Mac and then just take the code to Linux and compile it with g++?
For now I was able to do so but I'm not sure I will not encounter problems in the future. For example under Windows forks and sockets are done in completely different way, so i just would like to know where the differences are (OS X vs Ubuntu) to know I need to code that particular code under Linux.
Upvotes: 1
Views: 1770
Reputation: 328
Both are UNIX-like environnement. Therefore, as long as your code follows the POSIX standards, you should not be in trouble. However, I strongly encourage you to test your code on Ubuntu at different stage of your development. However, do not expect to find Apple library calls under Linux (and vice-versa).
Upvotes: 1
Reputation: 47563
OS X is Unix-based (like Linux) and follows POSIX (to some extent). If you use POSIX functions available in OS X, you should have no (or minimal at best) problems running the code under Linux.
The opposite is not true though, since Linux follows POSIX to a much higher degree and (almost) conforms to the newest POSIX standards, while OS X doesn't support the newer versions. Furthermore, GNU has many extensions both to POSIX tools and libraries that may not be available on OS X.
In short, under Linux you would have more up-to-date and feature-rich libraries to work with. However, the good-old functions of POSIX found in OS X are also available in Linux. So generally there shouldn't be a problem, so long as you stick to the standard behaviors.
Upvotes: 1