Previous Topic

Next Topic

Data Type Conventions

The actual representation of a data type declaration may vary from one operating environment or processor type to another. For instance, on one system the int data type may be represented by a 2-byte integer, while on another system int may be represented by a 4-byte integer. Our goal is to make a product using c-tree Plus as portable as possible. Differences like these between systems can interfere with that goal. We want to ensure that a 2-byte integer in c-tree Plus will be a 2-byte integer on any system. Therefore, we define our own data types as shown below. By carefully using these data types, you guarantee that a program operates consistently across all supported operating environments.

The following data types are used throughout the c-tree Plus routines called by your application programs. C language typedefs have been included in the c-tree Plus header files. Most of these will be found in the header file ctport.h.

We recommend that you use these conventions in your products, as well. By carefully avoiding the use of native variable types in your variable declarations you can create an application that is very easy to port from one compiler, or operating environment, to another

COUNT
COUNT parameters are used to pass values such as key length or file number to c-tree Plus functions. Most c-tree Plus functions return error codes of type COUNT. This is a 2-byte signed integer.

UCOUNT
UCOUNT parameters are used to pass fixed length data record lengths and file extension sizes to the c-tree Plus functions. This is a 2-byte unsigned integer.

LONG
LONG values represent data record positions. This is a 4-byte signed integer.

ULONG
This is a 4-byte unsigned integer.

TEXT
Character pointers to type TEXT are used to pass file names and key values to the c‑tree routines.

IFIL
Incremental ISAM structure. IFIL structures contain the parameters necessary to create, open, and close ISAM files without a parameter file. The ISAM parameters are discussed in ISAM Functions.

DATOBJ
The DATOBJ structure is the data type used in the Data Object Definition Array or DODA, which defines the record layout to c-tree Plus. See Record Schemas for additional information.

VRLEN
VRLEN is used to pass or receive a record length and buffer sizes.

UINT
UINT are native system unsigned integers.

VOID
VOID is used in two ways: to define functions that return no value, and to define a generic pointer. Some compilers do not support the declaration void, and others do. In ctport.h you will find a define similar to the following:

#define void void

If your compiler does not support the void declaration, substitute the following;

#define void int

VOID pointers are better than character or TEXT pointers when you are passing a variable address to a function, and you don’t know if you are going to use a character string or a structure. A VOID pointer is a generic pointer, and if you are using function prototyping, it will let you use any type of variable pointer. A TEXT pointer will give you a warning when you compile a program passing a structure address.

p TYPES
The lower case p indicates this data type is cast to be a pointer. For example, pCOUNT is equivalent to (COUNT *). Most of the data types defined by c-tree Plus have companion types prefaced with a lower case p (e.g., pVOID, pTEXT, . . .).