140266059SGregory Neil Shapiro<html> 240266059SGregory Neil Shapiro<head> 340266059SGregory Neil Shapiro <title>libsm : C Language Portability Macros</title> 440266059SGregory Neil Shapiro</head> 540266059SGregory Neil Shapiro<body> 640266059SGregory Neil Shapiro 740266059SGregory Neil Shapiro<a href="index.html">Back to libsm overview</a> 840266059SGregory Neil Shapiro 940266059SGregory Neil Shapiro<center> 1040266059SGregory Neil Shapiro <h1> libsm : C Language Portability Macros </h1> 11*4313cc83SGregory Neil Shapiro <br> $Id: cdefs.html,v 1.2 2000-12-07 17:33:09 dmoen Exp $ 1240266059SGregory Neil Shapiro</center> 1340266059SGregory Neil Shapiro 1440266059SGregory Neil Shapiro<h2> Description </h2> 1540266059SGregory Neil Shapiro 1640266059SGregory Neil ShapiroThe header file <tt><sm/cdefs.h></tt> 1740266059SGregory Neil Shapirodefines portable interfaces to non-portable features 1840266059SGregory Neil Shapiroof various C compilers. 1940266059SGregory Neil ShapiroIt also assists you in writing C header files that are compatible 2040266059SGregory Neil Shapirowith C++. 2140266059SGregory Neil Shapiro 2240266059SGregory Neil Shapiro<dl> 2340266059SGregory Neil Shapiro<dt> 2440266059SGregory Neil Shapiro<tt> __P(parameterlist) </tt> 2540266059SGregory Neil Shapiro<dd> 2640266059SGregory Neil Shapiro This macro is used to write portable function prototypes. 2740266059SGregory Neil Shapiro For example, 2840266059SGregory Neil Shapiro 2940266059SGregory Neil Shapiro<blockquote><pre> 3040266059SGregory Neil Shapiroint foo __P((int)); 3140266059SGregory Neil Shapiro</pre></blockquote> 3240266059SGregory Neil Shapiro 3340266059SGregory Neil Shapiro<dt> 3440266059SGregory Neil Shapiro<tt> __CONCAT(x,y) </tt> 3540266059SGregory Neil Shapiro<dd> 3640266059SGregory Neil Shapiro This macro concatenates two tokens x and y, 3740266059SGregory Neil Shapiro forming a single token xy. 3840266059SGregory Neil Shapiro Warning: make sure there is no white space around the arguments x and y. 3940266059SGregory Neil Shapiro <p> 4040266059SGregory Neil Shapiro 4140266059SGregory Neil Shapiro<dt> 4240266059SGregory Neil Shapiro<tt> __STRING(x) </tt> 4340266059SGregory Neil Shapiro<dd> 4440266059SGregory Neil Shapiro This macro converts the token sequence x into a string literal. 4540266059SGregory Neil Shapiro <p> 4640266059SGregory Neil Shapiro 4740266059SGregory Neil Shapiro<dt> 4840266059SGregory Neil Shapiro<tt> __BEGIN_DECLS, __END_DECLS </tt> 4940266059SGregory Neil Shapiro<dd> 5040266059SGregory Neil Shapiro These macros are used to write C header files that are compatible 5140266059SGregory Neil Shapiro with C++ compilers. 5240266059SGregory Neil Shapiro Put <tt>__BEGIN_DECLS</tt> before the first function or variable 5340266059SGregory Neil Shapiro declaration in your header file, 5440266059SGregory Neil Shapiro and put <tt>__END_DECLS</tt> after the last function or variable 5540266059SGregory Neil Shapiro declaration. 5640266059SGregory Neil Shapiro <p> 5740266059SGregory Neil Shapiro 5840266059SGregory Neil Shapiro<dt> 5940266059SGregory Neil Shapiro<tt> const, signed, volatile </tt> 6040266059SGregory Neil Shapiro<dd> 6140266059SGregory Neil Shapiro For pre-ANSI C compilers, <tt>const</tt>, <tt>signed</tt> 6240266059SGregory Neil Shapiro and <tt>volatile</tt> are defined as empty macros. 6340266059SGregory Neil Shapiro This means you can use these keywords without introducing 6440266059SGregory Neil Shapiro portability problems. 6540266059SGregory Neil Shapiro <p> 6640266059SGregory Neil Shapiro 6740266059SGregory Neil Shapiro<dt> 6840266059SGregory Neil Shapiro<tt> SM_DEAD(function_declaration) </tt> 6940266059SGregory Neil Shapiro<dd> 7040266059SGregory Neil Shapiro This macro modifies a prototype of a function 7140266059SGregory Neil Shapiro that does not return to its caller. 7240266059SGregory Neil Shapiro With some versions of gcc, this will result in slightly better code, 7340266059SGregory Neil Shapiro and can suppress some useless warnings produced by gcc -Wall. 7440266059SGregory Neil Shapiro For example, 7540266059SGregory Neil Shapiro 7640266059SGregory Neil Shapiro<blockquote><pre> 7740266059SGregory Neil ShapiroSM_DEAD(void exit __P((int))); 7840266059SGregory Neil Shapiro</pre></blockquote> 7940266059SGregory Neil Shapiro 8040266059SGregory Neil Shapiro<dt> 8140266059SGregory Neil Shapiro<tt> SM_UNUSED(variable_declaration) </tt> 8240266059SGregory Neil Shapiro<dd> 8340266059SGregory Neil Shapiro This macro modifies a definition of an unused 8440266059SGregory Neil Shapiro local variable, global variable or function parameter 8540266059SGregory Neil Shapiro in order to suppress compiler warnings. 8640266059SGregory Neil Shapiro Examples: 8740266059SGregory Neil Shapiro 8840266059SGregory Neil Shapiro<blockquote><pre> 89*4313cc83SGregory Neil ShapiroSM_UNUSED(static const char Id[]) = "@(#)$Id: cdefs.html,v 1.2 2000-12-07 17:33:09 dmoen Exp $"; 9040266059SGregory Neil Shapirovoid 9140266059SGregory Neil Shapirofoo(x) 9240266059SGregory Neil Shapiro SM_UNUSED(int x); 9340266059SGregory Neil Shapiro{ 9440266059SGregory Neil Shapiro SM_UNUSED(int y) = 0; 9540266059SGregory Neil Shapiro return 0; 9640266059SGregory Neil Shapiro} 9740266059SGregory Neil Shapirovoid 9840266059SGregory Neil Shapirobar(SM_UNUSED(int x)) 9940266059SGregory Neil Shapiro{ 10040266059SGregory Neil Shapiro return 0; 10140266059SGregory Neil Shapiro} 10240266059SGregory Neil Shapiro</pre></blockquote> 10340266059SGregory Neil Shapiro 10440266059SGregory Neil Shapiro</dl> 10540266059SGregory Neil Shapiro 10640266059SGregory Neil Shapiro</body> 10740266059SGregory Neil Shapiro</html> 108