-qnullterm

Category

Language element control

Purpose

Appends a null character to each character constant expression that is passed as a dummy argument, making it more convenient to pass strings to C functions.

This option allows you to pass strings to C functions without having to add a null character to each string argument.

Syntax

Read syntax diagramSkip visual syntax diagram
        .-nonullterm-.   
>>- -q--+-nullterm---+-----------------------------------------><

@PROCESS:

@PROCESS NULLTERM | NONULLTERM

Defaults

-qnonullterm

Usage

This option affects arguments that are composed of any of the following objects:
  • Basic character constants
  • Concatenations of multiple character constants
  • Named constants of type character
  • Hollerith constants
  • Binary, octal, or hexadecimal typeless constants when an interface block is available
  • Any character expression composed entirely of these objects.

The result values from the CHAR and ACHAR intrinsic functions also have a null character added to them if the arguments to the intrinsic function are constant expressions.

Rules

This option does not change the length of the dummy argument, which is defined by the additional length argument that is passed as part of the XL Fortran calling convention.

Restrictions

This option affects those arguments that are passed with or without the %REF built-in function, but it does not affect those that are passed by value. This option does not affect character expressions in input and output statements.

Examples

Here are two calls to the same C function; one with, and one without the option:
      @PROCESS NONULLTERM
      SUBROUTINE CALL_C_1
        CHARACTER*9, PARAMETER :: HOME = "/home/luc"
! Call the libc routine mkdir() to create some directories.
        CALL mkdir ("/home/luc/testfiles\0", %val(448))
! Call the libc routine unlink() to remove a file in the home directory.
        CALL unlink (HOME // "/.hushlogin" // CHAR(0))
      END SUBROUTINE

      @PROCESS NULLTERM
      SUBROUTINE CALL_C_2
        CHARACTER*9, PARAMETER :: HOME = "/home/luc"
! With the option, there is no need to worry about the trailing null
! for each string argument.
        CALL mkdir ("/home/luc/testfiles", %val(448))
        CALL unlink (HOME // "/.hushlogin")
      END SUBROUTINE
!

Related information

See Passing character types between languages .