Portability Guidelines
Refer to these guidelines to develop business functions that comply with portability standards:
Business functions must be ANSI-compatible for portability.
Since different computer platforms might present limitations, exceptions to this rule do exist. However, do not use a non-ANSI exception without approval from the Business Function Standards Committee.
Do not create a program that depends on data alignment, because each system aligns data differently by allocating bytes or words.
For example: for a one-character field that is one byte. Some systems allocate only one byte for that field, while other systems allocate the entire word for the field.
Keep in mind that vendor libraries and function calls are system-dependent and exclusive to that vendor.
This means that if the program is compiled using a different compiler, that particular function will fail.
Use caution when using pointer arithmetic because it is system-dependent and is based on the data alignment.
Do not assume that all systems will initialize a variable the same way.
Always explicitly initialize variables.
Use caution when using an offset to explicitly retrieve a value within the data structure.
This guideline also relates to data alignment. Use offset to define cache index.
Always typecast if your parameter does not match the function parameter.
Note:JCHAR szArray[13] is not the same as (JCHAR *) in the function declaration. Therefore, typecast of (JCHAR *) is required for szArray for that particular function.
Never typecast on the left-hand side of the assignment statement, as it can result in a loss of data.
For example, in the statement
(short)nValue = (long),lValue
will lose the value of the long integer if it is too large to fit into a short integer data type.Do not use C++ comments (C++ comments begin with two forward slashes).