In the Unix world, “portability” refers to porting to different Unix versions. For a GNU program, this kind of portability is desirable, but not paramount.
The primary purpose of GNU software is to run on top of the GNU kernel, compiled with the GNU C compiler, on various types of CPU. So the kinds of portability that are absolutely necessary are quite limited. But it is important to support Linux-based GNU systems, since they are the form of GNU that is popular.
Beyond that, it is good to support the other free operating systems (*BSD), and it is nice to support other Unix-like systems if you want to. Supporting a variety of Unix-like systems is desirable, although not paramount. It is usually not too hard, so you may as well do it. But you don’t have to consider it an obligation, if it does turn out to be hard.
The easiest way to achieve portability to most Unix-like systems is to use Autoconf. It’s unlikely that your program needs to know more information about the host platform than Autoconf can provide, simply because most of the programs that need such knowledge have already been written.
Avoid using the format of semi-internal data bases (e.g., directories)
when there is a higher-level alternative (
As for systems that are not like Unix, such as MSDOS, Windows, VMS, MVS, and older Macintosh systems, supporting them is often a lot of work. When that is the case, it is better to spend your time adding features that will be useful on GNU and GNU/Linux, rather than on supporting other incompatible systems.
If you do support Windows, please do not abbreviate it as “win”. See Trademarks.
Usually we write the name “Windows” in full, but when brevity is
very important (as in file names and some symbol names), we abbreviate
it to “w”. In GNU Emacs, for instance, we use ‘w32’ in file
names of Windows-specific files, but the macro for Windows
conditionals is called
WINDOWSNT. In principle there could
also be ‘w64’.
It is a good idea to define the “feature test macro”
_GNU_SOURCE when compiling your C files. When you compile on GNU
or GNU/Linux, this will enable the declarations of GNU library extension
functions, and that will usually give you a compiler error message if
you define the same function names in some other way in your program.
(You don’t have to actually use these functions, if you prefer
to make the program more portable to other systems.)
But whether or not you use these GNU extensions, you should avoid using their names for any other meanings. Doing so would make it hard to move your code into other GNU programs.