pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/doc/guide/files State of the art on OS testing macros
details: https://anonhg.NetBSD.org/pkgsrc/rev/ec187c128e2d
branches: trunk
changeset: 379656:ec187c128e2d
user: nia <nia%pkgsrc.org@localhost>
date: Sat May 21 11:30:57 2022 +0000
description:
State of the art on OS testing macros
diffstat:
doc/guide/files/fixes.xml | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diffs (60 lines):
diff -r 6eca666fcb6f -r ec187c128e2d doc/guide/files/fixes.xml
--- a/doc/guide/files/fixes.xml Sat May 21 11:24:28 2022 +0000
+++ b/doc/guide/files/fixes.xml Sat May 21 11:30:57 2022 +0000
@@ -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 @@
<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 @@
#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 @@
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>
Home |
Main Index |
Thread Index |
Old Index