mozilla
Your Search Results

    NSPR API Reference:NSPR Types

    This chapter describes the most common NSPR types. Other chapters describe more specialized types when describing the functions that use them.

    For information on naming conventions for NSPR types, functions, and macros, see NSPR Naming Conventions.

    Calling Convention Types

    These types are used to support cross-platform declarations of prototypes and implementations:

    • 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.

    Here are some simple examples of the use of these types:

    In dowhim.h:

    PR_EXTERN( void ) DoWhatIMean( void );
    
    static void PR_CALLBACK RootFunction(void *arg); 
    

    In dowhim.c:

    PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; };
    
    PRThread *thread = PR_CreateThread(..., RootFunction, ...);
    

    Algebraic Types

    NSPR provides the following type definitions with unambiguous bit widths for algebraic operations:

    For convenience, NSPR also provides type definitions with platform-dependent bit widths:

    8-, 16-, and 32-bit Integer Types

    Signed Integers
    Unsigned Integers

    64-bit Integer Types

    Different platforms treat 64-bit numeric fields in different ways. Some systems require emulation of 64-bit fields by using two 32-bit numeric fields bound in a structure. Since the types (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.

    Floating-Point Number Type

    The NSPR floating-point type is always 64 bits.

    Native OS Integer Types

    These types are most appropriate for automatic variables. They are guaranteed to be at least 16 bits, though various architectures may define them to be wider (for example, 32 or even 64 bits). These types are never valid for fields of a structure.

    Miscellaneous Types

    Size Type

    Pointer Difference Types

    Types for pointer difference. Variables of these types are suitable for storing a pointer or pointer subtraction. These are the same as the corresponding types in libc.

    Boolean Types

    Type and constants for Boolean values.

    Status Type for Return Values

    Document Tags and Contributors

    Contributors to this page: Anonymous
    Last updated by: Anonymous,