Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So far all my development in C++ has been targeted to Windows, however I have al

ID: 654243 • Letter: S

Question

So far all my development in C++ has been targeted to Windows, however I have always had it in the back of my mind that I will someday be targeting Linux. I am aware therefore of the need to select cross-platform libraries, and to keep my code as portable as possible (or provide alternative implementations for code which isn't portable). This question therefore does not relate to issues of code compilation.

I would like to know, what are some common issues that a developer will face when targeting both Linux and Windows? In particular, but not limited to:

Best practices for handling configuration files. On Windows it seems this is fairly arbitrary - I've seen software store their configuration inside the program folder, in the user's folder (under appData), and in the registry. On Linux it seems much more heavily weighted towards dedicated configuration folders (/etc). How should I handle these differences in my code? Do I hard code the locations, or is there some system-defined function I can consult?

Same as (1) but for logging.

How do I go about keeping my project files in sync? E.g. if I update something in a Visual Studio project file, do I generally need to manually update the equivalent thing in whatever Linux environment I'm working in, or is there a commonly used method of avoiding this?

What is the best way to handle platform implementation differences in my code? Should I use #ifdefs, or should I keep the platform-specific code in separate files and have the project specify which files are included?

Anything else I haven't thought of which I should start considering / researching?

Explanation / Answer

Emplacement of things. See the Filesystem Hierarchy Standard. Quick summary for configuration: machine configuration under /etc/opt/<package>, user configuration under $HOME/.<package>.

Logging, it means different things for different people. For a system tool, look syslog

That's the job of you VCS and shouldn't be very different from keeping several Windows machines in sync.

Find a library which provides an abstraction (starting with boost for instance)
Build such a library.
Use #ifdef for minor differences, for bigger things, see 2 if you can't find 1.
It is common to install server applications with their own user as a security measure. Look also for chroot.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote