|
NSPR Reference Previous Contents Next |
Algebraic Types of various lengths are used for integer algebra.
Miscellaneous Types are used for representing size, pointer difference, Boolean values, and return values.
PR_EXTERN is used for definitions of external functions or variables.
PR_IMPLEMENT is used for declarations of external functions or variables.
PR_CALLBACK is used for definitions and declarations of functions that are
called via function pointers. A typical example is a function implemented in an
application but called from a shared library.
PR_EXTERN( void ) DoWhatIMean( void );
static void PR_CALLBACK RootFunction(void *arg);
PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; };
PRThread *thread = PR_CreateThread(..., RootFunction, ...);
#include <prtypes.h>
PR_EXTERN(type) prototype
PR_EXTERN is used to define externally visible routines and globals. For syntax
details for each platform, see prtypes.h. The macro includes the proper
specifications to declare the target extern and set up other required linkages.
_) as the first
character of an exported symbol.
#include <prtypes.h>
PR_IMPLEMENT(type) implementation
PR_IMPLEMENT is used to define implementations of externally visible routines and
globals. For syntax details for each platform, see prtypes.h.
_) as the first
character of an exported symbol.
#include <prtypes.h>
type PR_CALLBACK implementation
PR_CALLBACK attribute. Normally such functions are passed by reference
(pointer to function). The PR_CALLBACK attribute is included as part of the
function's definition between its return value type and the function's name.
8-, 16-, and 32-bit Integer Types
64-bit Integer Types
Floating-Point Number Type
For convenience, NSPR also provides type definitions with platform-dependent bit widths:
#include <prtypes.h>
typedef definition PRInt8;
#include <prtypes.h>
typedef definition PRInt16;
#include <prtypes.h>
typedef definition PRInt32;
int or a long, depending on the platform. For syntax details
for each platform, see prtypes.h.
char.
#include <prtypes.h>
typedef definition PRUint8;
#include <prtypes.h>
typedef definition PRUint16;
#include <prtypes.h>
typedef definition PRUint32;
int or an unsigned long, depending on the
platform. For syntax details for each platform, see prtypes.h.
long long versus struct LONGLONG) are not type
compatible, NSPR defines macros to manipulate 64-bit numeric fields. These
macros are defined in prlong.h. Conscientious use of these macros ensures
portability of code to all the platforms supported by NSPR and still provides
optimal behavior on those systems that treat long long values directly.
#include <prtypes.h>
typedef definition PRInt64;
prtypes.h.
#include <prtypes.h>
typedef definition PRUint64;
prtypes.h.
#include <prtypes.h>
typedef double PRFloat64;
#include <prtypes.h>
typedef int PRIntn;
typedef unsigned int PRUintn;
lib.c.
#include <prtypes.h>
typedef size_t PRSize;
libc.
#include <prtypes.h>
typedef ptrdiff_t PRPtrdiff;
#include <prtypes.h>
typedef unsigned long PRUptrdiff;
#include <prtypes.h>
typedef enum { PR_FALSE = 0, PR_TRUE = 1 } PRBool;
PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE for
clarity of target type in assignments and actual arguments. Use if (bool), while
(!bool), (bool) ? x : y, and so on to test Boolean values, just as you would C
int-valued conditions.
#include <prtypes.h>
typedef PRUint8 PRPackedBool;
PRPackedBool within structures where bit fields are not desirable but
minimum and consistent overhead matters.
#include <prtypes.h>
typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
Last Updated May 18, 2001