C language programs

The following information describes some of the changes that are specific to C language programs:

  • Header file changes. The z/TPF-compatible compilers do not allow header file names with $ characters.
  • Differences between the IBM® C/C++ compiler and z/TPF-compatible compilers. For example, z/TPF-compatible compilers tend to be closer to ANSI compliance, while TPF 4.1 code, especially code that has not changed in a long time, will not be. You will probably have to change your application code based on what the results are when you compile your code with a z/TPF-compatible compiler. Some specific compiler differences are:
    • The GCC does not support trigraphs (under most circumstances) while the Systems/C and Systems/C++ compilers do support trigraphs.
    • The GCC expects the backslash (\) character to be the very last character on the line when it is used as a line continuation character.
  • 64-bit considerations:
    • With the z/TPF system, all C/C++ programs are compiled as 64 bit, which defines the size of a long data type as 8 bytes. With the TPF 4.1 system, all C/C++ programs are compiled as 32-bit, which defines the size of a long data type as 4 bytes. For both systems, the size of an integer data type is 4 bytes.

      To provide compatibility with the size of the fields contained in data structures that have corresponding assembler data areas (DSECTs), all long data types were changed to integer data types. As code was converted to 64 bit, selected fields were changed back to long data types as appropriate.

      You need to decide if the data type size change affects your applications and how you would like to make your changes.

    • Another 64-bit consideration is the use of pointers. When a C/C++ program is compiled as 64-bit, the size of a pointer data type is 8 bytes. Sometimes pointers are cast to integers for various reasons. To create code that is compatible for both 32-bit and 64-bit systems, change the casting from integer to long. The z/TPF-compatible compilers might produce a warning for pointers that are cast to integers.
      There might be some instances where you will continue to need a 4-byte pointer; for example, pointers to core blocks in the ECB cannot be increased to 8 bytes. To provide compatibility, a 31-bit pointer attribute called PTR32ATT and 31-bit pointer data types called __ptr32_t, __chptr32_t, and __uiptr32_t are provided. For single source compatibility, code the following statement:
      #include <sys/types.h>
    • When a C/C++ program passes a pointer to static or constant data to an assembler program, the called assembler program must handle the pointer as a true 64-bit pointer unless the C/C++ program is loaded below the 2 GB bar.
  • With the TPF 4.1 system, the standard template library is supported by STLPort. With the z/TPF system, the standard template library is supported by the GNU standard C++ library (libstdc++).
  • The TPF 4.1 system supports floating point data only in hexadecimal floating point (HFP) format. However, ELF-compatible compilers (and the z/TPF system) support only binary floating point (BFP) format. You can use the following functions to migrate your floating point data, and to maintain single source applications that run under both the TPF 4.1 system and the z/TPF system:
    • tpf__fp_htob
    • tpf__fp_btoh
    • tpf__fp_hton
    • tpf__fp_ntoh
    • tpf__fp_bton
    • tpf__fp_ntob.
Additional information:
  • See Migrating your application programs for more information about specific changes required for your application programs.
  • See Common errors and warnings for more information about specific compiler errors and warnings.
  • See Mapping data types for more information about the difference in data types.
  • See the z/TPF C/C++ Language Support User's Guide for more information about the floating point functions.
  • See the GNU website for more information about GCC.