c++ under Linux and Windows

Hi,
I want to know what is the difference between c++ programming under Windows and Linux.
you need a g++ tool in linux
[code]#include <windo ws.h> [/code]versus #include <sys/anything>
In no particular order here are some of my answers to your question:

These articles aren't a bad place to start, although they don't directly answer your question they do lay some ground work:

- http://en.wikipedia.org/wiki/POSIX

- http://en.wikipedia.org/wiki/Win32

To me the most noticeable difference between the two is accessibility to "kernel mode operations". In Windows access to things like hardware are done using a driver as an intermediary, this is partially done for security but another reason is to maintain a uniform interface across all of the platforms regardless of the make and model of the device. In some cases drivers are inserted into driver chains to ensure that they are used to filter commands that could harm the stability of the system. In the *nix family of operating systems there is little or no separation between user mode and kernel mode operations as long as they are executed as "sudo". If you want to do something that might crash the OS, *nix just assumes that's what you wanted to do.

I'm no where near as good programming on *nix as I am on Windows so I could be a little off on the next few, but I am confident that the gist of it is there.

Another difference between the two might be (see the disclaimer above) is how they each handle sessions. *nix really has no concept of Services like Windows does. Even though it runs plenty of programs automatically in the background all of which have the same functions as services would *nix doesn't choose to isolate them from Session 0 like Windows. So applications running on the desktop for example can freely communicate with these "background applications" just like they would with any other application running in memory and they are free to interface with the user.

Because most versions of Linux are free, and therefore there are no licensing restrictions, (I've been told) a programmer should plan that any application they write could be running on a workstation that has multiple instances-of-users-logged-in (what would be called "Stations" in the Win API). This means that relaying on critical locks for synchronization with resources is kind of a taboo and atomic operations are the norm more so then in Windows.

*nix doesn't use a Registry so user preferences need to be saved directly to the users profile (which I guess they are in Windows in the form of ntuser.dat). This also means that more "global" preferences such as hardware settings need to be saved as files.

There are a bunch more but these were some off the top of my head.
Last edited on
Topic archived. No new replies allowed.