Try OpenEdge Now
skip to main content
Programming Interfaces
External Program Interfaces : Host Language Call Interface : Writing C functions : C function portability
 
C function portability
C code is portable from one operating system to another when you can compile, link, and run it without change on either operating system. If you plan to port your HLC application, make your C functions as portable as possible. The following tips can help increase the portability of your C code:
*Avoid operating-system-specific calls. Proposed UNIX-style portable operating system standards exist (POSIX, XOPEN), but their acceptance is limited. OpenEdge runs on operating systems that do not support these standards.
*If you must make operating-system-specific calls, hide them behind a standard application interface of your own design. If possible, confine the interface definition and all operating-system-specific code to a single source module, where you can modify it easily.
*Use the UNIX lint utility if it is available on your system. The lint utility flags C language statements in your code that are potential sources of portability problems. See your system documentation for information on using lint or its equivalent.
*When you pass a value to a function, cast it to the data type the function expects. For example, the following function call casts the number 23 as a long:
sample_function((long)23);
*Do not use C functions when you can use standard ABL code.
*Do not write your own function if there is an HLC library function that provides the same functionality.