Contents of C/C++ source files

The following table describes how to name the C/C++ item that is in a C or C++ source file; these are the actual contents, not the external source file name. These conventions are in place to avoid clashing with namespaces of customers if a header is included in and compiled with customer source code.

Table 1. Naming standards for C/C++ source code (contents of file)
Item in C/C++ source file z/TPF - interface protected (interface guaranteed) z/TPF - implementation specific (interface not guaranteed) BAL equivalent exists
identifiers
  • functions
  • data

macro (#define)

typedef

enumeration
  • tag
  • value
tags³
  • structure⁴
  • union
exported
  • functions5
  • data
One of the following¹:
  • tpf_
  • TPF_
  • tpfxxx_
  • TPFxxx_ where xxx is a package or feature code that will allow the names to be grouped together in information and also self-document to which package they belong.
  • df_
  • DF_
  • dfxxx_
  • DFxxx_
  • __dbxxx
Anything One of the following:²
  • TPF_name
  • TPF_name_xxx
  • tpf_name
  • tpf_name_xxx
Table notes:
  1. TO2_ functions are exceptions to this naming convention. They will not be renamed.
  2. All existing z/TPF DSECTs will not be renamed and are exceptions.
  3. Global tags and system equates migrated from Assembler to C language:
    • Use an underscore character followed by the name in lowercase when naming global variables. For example, global assembler tag @globz would be _globz in C. Except for the underscore (_) substitution, names should follow the existing assembler standard.
    • Use uppercase characters when naming constants. Replace the # at the start of some system constants with an underscore character (_). Comment on the use or purpose of all constant values.
      The following assembler system equates
      
      #SYSEQ    EQU     12       maximum number of jobs allowed in system
      WIGITCNT  EQU     42       number of wigits supported
      
      become, in C
      
      #define _SYSEQ    12    /* maximum number of jobs allowed in system */
      #define WIGITCNT  42    /* number of wigits supported               */
  4. If a C or C++ header is created for an existing BAL DSECT, prefix the C or C++ structure name with TPF_ or tpf_. If there is an existing BAL DSECT, member names in the C or C++ structure are the same as in the corresponding BAL DSECT.
  5. See Exported symbol names for C shared objects (CSOs) that are used by applications and Generally reserved names for the z/TPF system for more information about naming standards when you are creating (or porting and changing) a new C/C++ function.