190792Sgshapiro<html> 290792Sgshapiro<head> 390792Sgshapiro <title>libsm : C Language Portability Macros</title> 490792Sgshapiro</head> 590792Sgshapiro<body> 690792Sgshapiro 790792Sgshapiro<a href="index.html">Back to libsm overview</a> 890792Sgshapiro 990792Sgshapiro<center> 1090792Sgshapiro <h1> libsm : C Language Portability Macros </h1> 11266711Sgshapiro <br> $Id: cdefs.html,v 1.2 2000-12-07 17:33:09 dmoen Exp $ 1290792Sgshapiro</center> 1390792Sgshapiro 1490792Sgshapiro<h2> Description </h2> 1590792Sgshapiro 1690792SgshapiroThe header file <tt><sm/cdefs.h></tt> 1790792Sgshapirodefines portable interfaces to non-portable features 1890792Sgshapiroof various C compilers. 1990792SgshapiroIt also assists you in writing C header files that are compatible 2090792Sgshapirowith C++. 2190792Sgshapiro 2290792Sgshapiro<dl> 2390792Sgshapiro<dt> 2490792Sgshapiro<tt> __P(parameterlist) </tt> 2590792Sgshapiro<dd> 2690792Sgshapiro This macro is used to write portable function prototypes. 2790792Sgshapiro For example, 2890792Sgshapiro 2990792Sgshapiro<blockquote><pre> 3090792Sgshapiroint foo __P((int)); 3190792Sgshapiro</pre></blockquote> 3290792Sgshapiro 3390792Sgshapiro<dt> 3490792Sgshapiro<tt> __CONCAT(x,y) </tt> 3590792Sgshapiro<dd> 3690792Sgshapiro This macro concatenates two tokens x and y, 3790792Sgshapiro forming a single token xy. 3890792Sgshapiro Warning: make sure there is no white space around the arguments x and y. 3990792Sgshapiro <p> 4090792Sgshapiro 4190792Sgshapiro<dt> 4290792Sgshapiro<tt> __STRING(x) </tt> 4390792Sgshapiro<dd> 4490792Sgshapiro This macro converts the token sequence x into a string literal. 4590792Sgshapiro <p> 4690792Sgshapiro 4790792Sgshapiro<dt> 4890792Sgshapiro<tt> __BEGIN_DECLS, __END_DECLS </tt> 4990792Sgshapiro<dd> 5090792Sgshapiro These macros are used to write C header files that are compatible 5190792Sgshapiro with C++ compilers. 5290792Sgshapiro Put <tt>__BEGIN_DECLS</tt> before the first function or variable 5390792Sgshapiro declaration in your header file, 5490792Sgshapiro and put <tt>__END_DECLS</tt> after the last function or variable 5590792Sgshapiro declaration. 5690792Sgshapiro <p> 5790792Sgshapiro 5890792Sgshapiro<dt> 5990792Sgshapiro<tt> const, signed, volatile </tt> 6090792Sgshapiro<dd> 6190792Sgshapiro For pre-ANSI C compilers, <tt>const</tt>, <tt>signed</tt> 6290792Sgshapiro and <tt>volatile</tt> are defined as empty macros. 6390792Sgshapiro This means you can use these keywords without introducing 6490792Sgshapiro portability problems. 6590792Sgshapiro <p> 6690792Sgshapiro 6790792Sgshapiro<dt> 6890792Sgshapiro<tt> SM_DEAD(function_declaration) </tt> 6990792Sgshapiro<dd> 7090792Sgshapiro This macro modifies a prototype of a function 7190792Sgshapiro that does not return to its caller. 7290792Sgshapiro With some versions of gcc, this will result in slightly better code, 7390792Sgshapiro and can suppress some useless warnings produced by gcc -Wall. 7490792Sgshapiro For example, 7590792Sgshapiro 7690792Sgshapiro<blockquote><pre> 7790792SgshapiroSM_DEAD(void exit __P((int))); 7890792Sgshapiro</pre></blockquote> 7990792Sgshapiro 8090792Sgshapiro<dt> 8190792Sgshapiro<tt> SM_UNUSED(variable_declaration) </tt> 8290792Sgshapiro<dd> 8390792Sgshapiro This macro modifies a definition of an unused 8490792Sgshapiro local variable, global variable or function parameter 8590792Sgshapiro in order to suppress compiler warnings. 8690792Sgshapiro Examples: 8790792Sgshapiro 8890792Sgshapiro<blockquote><pre> 89266711SgshapiroSM_UNUSED(static const char Id[]) = "@(#)$Id: cdefs.html,v 1.2 2000-12-07 17:33:09 dmoen Exp $"; 9090792Sgshapirovoid 9190792Sgshapirofoo(x) 9290792Sgshapiro SM_UNUSED(int x); 9390792Sgshapiro{ 9490792Sgshapiro SM_UNUSED(int y) = 0; 9590792Sgshapiro return 0; 9690792Sgshapiro} 9790792Sgshapirovoid 9890792Sgshapirobar(SM_UNUSED(int x)) 9990792Sgshapiro{ 10090792Sgshapiro return 0; 10190792Sgshapiro} 10290792Sgshapiro</pre></blockquote> 10390792Sgshapiro 10490792Sgshapiro</dl> 10590792Sgshapiro 10690792Sgshapiro</body> 10790792Sgshapiro</html> 108