When you declare an external function in PocketBuilder, the datatypes of the arguments must correspond with the datatypes as declared in the function’s source definition. This section documents the correspondence between datatypes in external functions and datatypes in PocketBuilder. It also includes information on byte alignment when passing structures by value.
Use the tables to find out what PocketBuilder datatype to use in an external function declaration. The PocketBuilder datatype you select depends on the datatype in the source code for the function. The first column lists datatypes in source code. The second column describes the datatype so you know exactly what it is. The third column lists the PocketBuilder datatype you should use in the external function declaration.
BOOL on Windows is 16-bit, signed. It is declared in PocketBuilder as boolean.
Datatype in source code |
Size |
PocketBuilder datatype |
---|---|---|
* (any pointer) |
32-bit pointer |
Long |
byte * |
Array of bytes of variable length |
Blob |
Windows 32-bit FAR pointers, such as LPBYTE, LPDWORD, LPINT, LPLONG, LPVOID, and LPWORD, are declared in PocketBuilder as long datatypes. HANDLE is defined as 32 bits unsigned and is declared in PocketBuilder as an UnsignedLong.
Near-pointer datatypes (such as PSTR and NPSTR) are not supported in PocketBuilder.
Datatype in source code |
Size |
PocketBuilder datatype |
---|---|---|
char |
16 bit Unicode |
Char |
string |
32-bit pointer to a null-terminated array of Unicode characters of variable length |
String |
The Windows 32-bit FAR pointer LPSTR is declared in PocketBuilder as string.
Reference arguments When you pass a string to an external function by reference, all memory management is done in PocketBuilder. The string variable must be long enough to hold the returned value. To ensure that this is true, first declare the string variable, and then use the Space function to fill the variable with blanks equal to the maximum number of characters that you expect the function to return.
Datatype in source code |
Size |
PocketBuilder datatype |
---|---|---|
short |
16 bits, signed |
Integer |
unsigned short |
16 bits, unsigned |
UnsignedInteger |
int |
32 bits, signed |
Long |
unsigned int |
32 bits, unsigned |
UnsignedLong |
long |
32 bits, signed |
Long |
unsigned long |
32 bits, unsigned |
UnsignedLong |
longlong |
64 bits, signed |
LongLong |
The Windows definition WORD is declared in PocketBuilder as UnsignedInteger and the Windows definition DWORD is declared as an UnsignedLong. You cannot call external functions with return values or arguments of type short.
Datatype in source code |
Size and precision |
PocketBuilder datatype |
---|---|---|
float |
32 bits, single precision |
Real |
double |
64 bits, double precision |
Double |
PocketBuilder does not support 80-bit doubles on Windows.
The PocketBuilder datatypes Date, DateTime, and Time are structures and have no direct equivalent for external functions in C.
You can pass PocketBuilder structures to external C functions if they have the same definitions and alignment as the structure’s components. The DLL or shared library must be compiled using byte alignment; no padding is added to align fields within the structure.