cdefs.html revision 266692
1255071Smarkm<html>
2255071Smarkm<head>
3255071Smarkm    <title>libsm : C Language Portability Macros</title>
4255071Smarkm</head>
5255071Smarkm<body>
6255071Smarkm
7255071Smarkm<a href="index.html">Back to libsm overview</a>
8255071Smarkm
9255071Smarkm<center>
10255071Smarkm    <h1> libsm : C Language Portability Macros </h1>
11255071Smarkm    <br> $Id: cdefs.html,v 1.2 2000-12-07 17:33:09 dmoen Exp $
12255071Smarkm</center>
13255071Smarkm
14255071Smarkm<h2> Description </h2>
15255071Smarkm
16255071SmarkmThe header file <tt>&lt;sm/cdefs.h&gt;</tt>
17255071Smarkmdefines portable interfaces to non-portable features
18255071Smarkmof various C compilers.
19255071SmarkmIt also assists you in writing C header files that are compatible
20255071Smarkmwith C++.
21255071Smarkm
22255071Smarkm<dl>
23255071Smarkm<dt>
24255071Smarkm<tt> __P(parameterlist) </tt>
25255071Smarkm<dd>
26255071Smarkm    This macro is used to write portable function prototypes.
27255071Smarkm    For example,
28255071Smarkm
29256381Smarkm<blockquote><pre>
30256381Smarkmint foo __P((int));
31255071Smarkm</pre></blockquote>
32255071Smarkm
33255071Smarkm<dt>
34255071Smarkm<tt> __CONCAT(x,y) </tt>
35255071Smarkm<dd>
36255071Smarkm    This macro concatenates two tokens x and y,
37256381Smarkm    forming a single token xy.
38255071Smarkm    Warning: make sure there is no white space around the arguments x and y.
39255071Smarkm    <p>
40256381Smarkm
41255071Smarkm<dt>
42256381Smarkm<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