xref: /freebsd/contrib/sendmail/libsm/cdefs.html (revision 911f0260390e18cf85f3dbf2c719b593efdc1e3c)
1<html>
2<head>
3    <title>libsm : C Language Portability Macros</title>
4</head>
5<body>
6
7<a href="index.html">Back to libsm overview</a>
8
9<center>
10    <h1> libsm : C Language Portability Macros </h1>
11    <br> $Id: cdefs.html,v 1.2 2000-12-07 17:33:09 dmoen Exp $
12</center>
13
14<h2> Description </h2>
15
16The header file <tt>&lt;sm/cdefs.h&gt;</tt>
17defines portable interfaces to non-portable features
18of various C compilers.
19It also assists you in writing C header files that are compatible
20with C++.
21
22<dl>
23<dt>
24<tt> __P(parameterlist) </tt>
25<dd>
26    This macro is used to write portable function prototypes.
27    For example,
28
29<blockquote><pre>
30int foo __P((int));
31</pre></blockquote>
32
33<dt>
34<tt> __CONCAT(x,y) </tt>
35<dd>
36    This macro concatenates two tokens x and y,
37    forming a single token xy.
38    Warning: make sure there is no white space around the arguments x and y.
39    <p>
40
41<dt>
42<tt> __STRING(x) </tt>
43<dd>
44    This macro converts the token sequence x into a string literal.
45    <p>
46
47<dt>
48<tt> __BEGIN_DECLS, __END_DECLS </tt>
49<dd>
50    These macros are used to write C header files that are compatible
51    with C++ compilers.
52    Put <tt>__BEGIN_DECLS</tt> before the first function or variable
53    declaration in your header file,
54    and put <tt>__END_DECLS</tt> after the last function or variable
55    declaration.
56    <p>
57
58<dt>
59<tt> const, signed, volatile </tt>
60<dd>
61    For pre-ANSI C compilers, <tt>const</tt>, <tt>signed</tt>
62    and <tt>volatile</tt> are defined as empty macros.
63    This means you can use these keywords without introducing
64    portability problems.
65    <p>
66
67<dt>
68<tt> SM_DEAD(function_declaration) </tt>
69<dd>
70    This macro modifies a prototype of a function
71    that does not return to its caller.
72    With some versions of gcc, this will result in slightly better code,
73    and can suppress some useless warnings produced by gcc -Wall.
74    For example,
75
76<blockquote><pre>
77SM_DEAD(void exit __P((int)));
78</pre></blockquote>
79
80<dt>
81<tt> SM_UNUSED(variable_declaration) </tt>
82<dd>
83    This macro modifies a definition of an unused
84    local variable, global variable or function parameter
85    in order to suppress compiler warnings.
86    Examples:
87
88<blockquote><pre>
89SM_UNUSED(static const char Id[]) = "@(#)$Id: cdefs.html,v 1.2 2000-12-07 17:33:09 dmoen Exp $";
90void
91foo(x)
92	SM_UNUSED(int x);
93{
94	SM_UNUSED(int y) = 0;
95	return 0;
96}
97void
98bar(SM_UNUSED(int x))
99{
100	return 0;
101}
102</pre></blockquote>
103
104</dl>
105
106</body>
107</html>
108