pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/doc/guide/files Added more documentation on the predef...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/e70cdefef8e5
branches:  trunk
changeset: 503475:e70cdefef8e5
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Nov 21 09:27:04 2005 +0000

description:
Added more documentation on the predefined C preprocessor macros.

diffstat:

 doc/guide/files/fixes.xml |  46 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 37 insertions(+), 9 deletions(-)

diffs (87 lines):

diff -r 215a50a194b6 -r e70cdefef8e5 doc/guide/files/fixes.xml
--- a/doc/guide/files/fixes.xml Mon Nov 21 09:24:01 2005 +0000
+++ b/doc/guide/files/fixes.xml Mon Nov 21 09:27:04 2005 +0000
@@ -1,4 +1,4 @@
-<!-- $NetBSD: fixes.xml,v 1.38 2005/11/13 03:27:20 minskim Exp $ -->
+<!-- $NetBSD: fixes.xml,v 1.39 2005/11/21 09:27:04 rillig Exp $ -->
 
 <chapter id="fixes"> <?dbhtml filename="fixes.html"?>
   <title>Making your package work</title>
@@ -838,9 +838,9 @@
 <programlisting><![CDATA[
     #include <sys/param.h>
     #if (defined(BSD) && BSD >= 199306)
-      /* your BSD-specific code goes here */
+      /* BSD-specific code goes here */
     #else
-      /* non-BSD-specific code */
+      /* non-BSD-specific code goes here */
     #endif
 ]]></programlisting>
 
@@ -854,7 +854,7 @@
     Linux       linux, __linux, __linux__
     NetBSD      __NetBSD__
     OpenBSD     __OpenBSD__
-    Solaris     sun, __sun (GCC and SunPro), __sun__ (only GCC)
+    Solaris     sun, __sun
 </programlisting>
 
       </sect3><sect3 id="fixes-build-cpp-cpu">
@@ -871,23 +871,51 @@
 
 <programlisting>
     GCC         __GNUC__ (major version), __GNUC_MINOR__
+    SunPro     __SUNPRO_C (0x570 for version 5.7)
 </programlisting>
 
       </sect3>
     </sect2>
 
+    <sect2 id="cpp-list-examples">
+      <title>Examples of CPP defines for some platforms</title>
+
+      <para>The list of the CPP identification macros for hardware and
+      operating system may depend on the compiler that is used. The
+      following list contains some examples that may help you to choose
+      the right ones. For example, if you want to conditionally compile
+      code on Solaris, don't use <varname>__sun__</varname>, as the
+      SunPro compiler does not define it. Use <varname>__sun</varname>
+      instead.</para>
+
+      <variablelist>
+       <varlistentry><term>SunPro 5.7 + Solaris 8 + SPARC</term>
+        <listitem><para>__SVR4 __sparc __sun __unix sparc sun
+        unix</para></listitem></varlistentry>
+
+       <varlistentry><term>GCC 4 + Solaris 8 + SPARC</term>
+        <listitem><para>__ELF__ __sparc __sparc__ __sun __sun__ __SVR4
+        __svr4__ __unix __unix__ sparc sun unix</para></listitem>
+        </varlistentry>
+
+      </variablelist>
+    </sect2>
+
     <sect2 id="cpp-list">
       <title>Getting a list of CPP defines</title>
 
-      <para>
-       When your system uses the GNU C Compiler, you can get a list
-       of symbols that are defined by default, e.g. to identify 
-       the platform, with the following command:
-      </para>
+      <para>If your system uses the GNU C Compiler, you can get a list
+      of symbols that are defined by default, e.g. to identify  the
+      platform, with the following command:</para>
 
 <programlisting>
     <![CDATA[gcc -E -dM - < /dev/null ]]>
 </programlisting>
+
+      <para>On other systems you may get the list by using the system's
+      syscall trace utility (ktrace, truss, strace) to have a look which
+      arguments are passed to the actual compiler.</para>
+
     </sect2>
   </sect1>
   



Home | Main Index | Thread Index | Old Index