summaryrefslogtreecommitdiff
path: root/doc/guide
diff options
context:
space:
mode:
authornia <nia@pkgsrc.org>2022-05-21 11:30:57 +0000
committernia <nia@pkgsrc.org>2022-05-21 11:30:57 +0000
commitee6a7581e798f6c095913bd04cf9dbd92e0ee55d (patch)
tree921df1d42f4173f3ac88b00fad770a1e2fafa40c /doc/guide
parent5ac75106b1be9ff438affcfa816613d60646c53e (diff)
downloadpkgsrc-ee6a7581e798f6c095913bd04cf9dbd92e0ee55d.tar.gz
State of the art on OS testing macros
Diffstat (limited to 'doc/guide')
-rw-r--r--doc/guide/files/fixes.xml26
1 files changed, 22 insertions, 4 deletions
diff --git a/doc/guide/files/fixes.xml b/doc/guide/files/fixes.xml
index 515ebe691de..fe4d20e2d91 100644
--- a/doc/guide/files/fixes.xml
+++ b/doc/guide/files/fixes.xml
@@ -1,4 +1,4 @@
-<!-- $NetBSD: fixes.xml,v 1.173 2022/05/21 11:24:28 nia Exp $ -->
+<!-- $NetBSD: fixes.xml,v 1.174 2022/05/21 11:30:57 nia Exp $ -->
<chapter id="fixes"> <?dbhtml filename="fixes.html"?>
<title>Making your package work</title>
@@ -1603,6 +1603,24 @@ pre-configure:
<sect3 id="fixes.build.cpp.os">
<title>C preprocessor macros to identify the operating system</title>
+ <para>To distinguish between specific NetBSD versions,
+ you should use the following code.</para>
+
+<programlisting>
+#ifdef __NetBSD__
+#include <sys/param.h>
+#if __NetBSD_Prereq__(9,99,17)
+/* use a newer feature */
+#else
+/* older code */
+#endif
+#endif
+
+#ifndef _WIN32
+/* Unix-like specific code */
+#endif
+</programlisting>
+
<para>To distinguish between 4.4 BSD-derived systems and the
rest of the world, you should use the following code.</para>
@@ -1615,8 +1633,7 @@ pre-configure:
#endif
</programlisting>
- <para>If this distinction is not fine enough, you can also test
- for the following macros.</para>
+ <para>You can also test for the following macros:</para>
<programlisting>
Cygwin __CYGWIN__
@@ -1625,13 +1642,14 @@ FreeBSD __FreeBSD__
Haiku __HAIKU__
Interix __INTERIX
IRIX __sgi (TODO: get a definite source for this)
-Linux linux, __linux, __linux__
+Linux __linux
Mac OS X __APPLE__
MirBSD __MirBSD__ (__OpenBSD__ is also defined)
Minix3 __minix
NetBSD __NetBSD__
OpenBSD __OpenBSD__
Solaris sun, __sun
+Unix(-like) __unix
</programlisting>
</sect3>