LSEARCH | NOLSEARCH

Category

Compiler input

Pragma equivalent

None.

Purpose

Specifies the directories or data sets to be searched for user include files.

When the LSEARCH compiler option is in effect, the preprocessor looks for the user include files in the specified directories or data sets.

When the NOLSEARCH compiler option is in effect, the preprocessor only searches those data sets that are specified in the USERLIB DD statement. A NOLSEARCH option cancels all previous LSEARCH specifications, and the compiler uses any LSEARCH options that follow it.

Syntax

Read syntax diagramSkip visual syntax diagramNOLSELSE(,path)

Defaults

NOLSEARCH

Parameters

path
Specifies any of the following:
  • The name of a partitioned or sequential data set that contains user include files.
  • A z/OS® UNIX System Services file system path that contains user include files.
  • A search path that is more complex:
Read syntax diagramSkip visual syntax diagramNOLSELSE(,//opt)

You must use the double slashes (//) to specify data set library searches when you specify the OE compiler option. (You may use them regardless of the OE option).

The USERLIB ddname is considered the last suboption for LSEARCH, so that specifying LSEARCH (X) is equivalent to specifying LSEARCH (X,DD:USERLIB).

Parts of the #include filename are appended to each LSEARCH opt to search for the include file. opt has the format:

Read syntax diagramSkip visual syntax diagram',qualifier.+␠.*␠'' +  * ',directory./..//DD:name(fname.suffix)=LIB(,subopt)
In this syntax diagram, opt specifies one of the following:
  • The name of a partitioned or sequential data set that contains user include files
  • A z/OS UNIX file system path name that should be searched for the include file. You can also use ./ to specify the current directory and ../ to specify the parent directory for your z/OS UNIX file.
  • A DD statement for a sequential data set or a partitioned data set. When you specify a ddname in the search and the include file has a member name, the member name of the include file is used as the name for the DD: name search suboption, for example:
    LSEARCH(DD:NEWLIB)
    #include "a.b(c)"
    The resulting file name is DD:NEWLIB(C).
  • A specification of the form (fname.suffix) = (subopt,subopt,...) where:
    • fname is the name of the include file, or *
    • suffix is the suffix of the include file, or *
    • subopt indicates a subpath to be used in the search for the include files that match the pattern of fname.suffix. There should be at least one subopt. The possible values are:
      • LIB([pds,...]) where each pds is a partitioned data set name. They are searched in the same order as they are specified.

        There is no effect on the search path if no pds is specified, but a warning is issued.

      • LIBs are cumulative; for example, LIB(A),LIB(B) is equivalent to LIB(A, B).
      • NOLIB specifies that all LIB(...) previously specified for this pattern should be ignored at this point.

When the #include filename matches the pattern of fname.suffix, the search continues according to the subopts in the order specified. An asterisk (*) in fname or suffix matches anything. If the compiler does not find the file, it attempts other searches according to the remaining options in LSEARCH.

Usage

When you specify more than one LSEARCH option, the compiler uses all the directories or data sets in these LSEARCH options to find the user include files.

The #include "filename" format of the #include C/C++ preprocessor directive indicates user include files. See Using include files for a description of the #include preprocessor directive.

Note: If the filename in the #include directive is in absolute form, the compiler does not perform a search. See Determining whether the file name is in absolute form for more details on absolute #include filename.

For further information on search sequences, see Search sequences for include files.

When specifying z/OS UNIX library searches, do not put double slashes at the beginning of the LSEARCH opt . Use pathnames separated by slashes (/) in the LSEARCH opt for a z/OS UNIX library. When the LSEARCH opt does not start with double slashes, any single slash in the name indicates a z/OS UNIX library. If you do not have path separators (/), then setting the OE compile option on indicates that this is a z/OS UNIX library; otherwise the library is interpreted as a data set. See Using SEARCH and LSEARCH for additional information on z/OS UNIX files.

Example: The opt specified for LSEARCH is combined with the filename in #include to form the include file name:
LSEARCH(/u/mike/myfiles)
#include "new/headers.h"
The resulting z/OS UNIX file name is /u/mike/myfiles/new/headers.h.

Use an asterisk (*) or a plus sign (+) in the LSEARCH opt to specify whether the library is a sequential or partitioned data set.

When you want to specify a set of PDSs as the search path, you add a period followed by a plus sign (.+) at the end of the last qualifier in the opt. If you do not have any qualifier, specify a single plus sign (+) as the opt. The opt has the following syntax for specifying partitioned data set:

Read syntax diagramSkip visual syntax diagram' + ,qualifier.+␠'

where qualifier is a data set qualifier.

Start and end the opt with single quotation marks (') to indicate that this is an absolute data set specification. Single quotation marks around a single plus sign (+) indicate that the filename that is specified in #include is an absolute partitioned data set.

When you do not specify a member name with the #include directive, for example, #include "PR1.MIKE.H", the PDS name for the search is formed by replacing the plus sign with the following parts of the filename of the #include directive:

  • For the PDS file name:
    1. All the paths and slashes (slashes are replaced by periods)
    2. All the periods and qualifiers after the left-most qualifier
  • For the PDS member name, the left-most qualifier is used as the member name

See the first example in Table 1.

However, if you specified a member name in the filename of the #include directive, for example, #include "PR1.MIKE.H(M1)", the PDS name for the search is formed by replacing the plus sign with the qualified name of the PDS. See the second example in Table 1.

See Forming data set names with LSEARCH | SEARCH options for more information on forming PDS names.

Note: To specify a single PDS as the opt, do not specify a trailing asterisk (*) or plus sign (+). The library is then treated as a PDS but the PDS name is formed by just using the leftmost qualifier of the #include filename as the member name. For example:
LSEARCH(AAAA.BBBB)
#include "sys/ff.gg.hh"

Resulting PDS name is
userid.AAAA.BBBB(FF)
Also see the third example in Table 1.

Predefined macros

None.

Examples

To search for PDS or PDSE files when you have coded your include files as follows:
#include "sub/fred.h"
#include "fred.inl"
You specified LSEARCH as follows:
LSEARCH(USER.+,'USERID.GENERAL.+')

The compiler uses the following search sequence to look for your include files:

  1. First, the compiler looks for sub/fred.h in this data set:
    USERID.USER.SUB.H(FRED)
  2. If that PDS member does not exist, the compiler looks in the data set:
    USERID.GENERAL.SUB.H(FRED)
  3. If that PDS member does not exist, the compiler looks in DD:USERLIB, and then checks the system header files.
  4. Next, the compiler looks for fred.inl in the data set:
    USERID.USER.INL(FRED)
  5. If that PDS member does not exist, the compiler will look in the data set:
    USERID.GENERAL.INL(FRED)
  6. If that PDS member does not exist, the compiler looks in DD:USERLIB, and then checks the system header files.

The compiler forms the search path for z/OS UNIX files by appending the path and name of the #include file to the path that you specified in the LSEARCH option.

Example 1: See the following example.
You code #include "sub/fred.h" and specify:
LSEARCH(/u/mike)
The compiler looks for the include file /u/mike/sub/fred.h .
Example 2: See the following example.
You specify your header file as #include "fred.h", and your LSEARCH option as:
LSEARCH(/u/mike, ./sub)

The compiler uses the following search sequence to look for your include files:

  1. The compiler looks for fred.h in /u/mike/fred.h.
  2. If that z/OS UNIX file does not exist, the compiler looks in ./sub/fred.h.
  3. If that z/OS UNIX file does not exist, the compiler looks in the libraries specified on the USERLIB DD statement.
  4. If USERLIB DD is not allocated, the compiler follows the search order for system include files.
The following example shows you how to specify a PDS search path:
Table 1. Partitioned data set examples
include Directive LSEARCH option Result
#include "PR1.MIKE.H" LSEARCH('CC.+') 'CC.MIKE.H(PR1)'
#include "PR.KE.H(M1)" LSEARCH('CC.+') 'CC.PR.KE.H(M1)'
#include "A.B" LSEARCH(CC) userid.CC(A)
#include "A.B.D" LSEARCH(CC.+) userid.CC.B.D(A)
#include "a/b/dd.h" LSEARCH('CC.+') 'CC.A.B.H(DD)'
#include "a/dd.ee.h" LSEARCH('CC.+') 'CC.A.EE.H(DD)'
#include "a/b/dd.h" LSEARCH('+') 'A.B.H(DD)'
#include "a/b/dd.h" LSEARCH(+) userid.A.B.H(DD)
#include "A.B(C)" LSEARCH('D.+') 'D.A.B(C)'

When you want to specify a set of sequential data sets as the search path, you add a period followed by an asterisk (.*) at the end of the last qualifier in the opt. If you do not have any qualifiers, specify one asterisk (*) as the opt. The opt has the following syntax for specifying a sequential data set:

Read syntax diagramSkip visual syntax diagram//' * ,qualifier. *'

where qualifier is a data set qualifier.

Start and end the opt with single quotation marks (') to indicate that this is an absolute data set specification. Single quotation marks (') around a single asterisk (*) means that the file name that is specified in #include is an absolute sequential data set.

The asterisk is replaced by all of the qualifiers and periods in the #include filename to form the complete name for the search (as shown in the following table).

The following example shows you how to specify a search path for a sequential data set:
Table 2. Sequential data set examples
include Directive LSEARCH option Result
#include "A.B" LSEARCH(CC.*) userid.CC.A.B
#include "a/b/dd.h" LSEARCH('CC.*') 'CC.DD.H'
#include "a/b/dd.h" LSEARCH('*') 'DD.H'
#include "a/b/dd.h" LSEARCH(*) userid.DD.H
Note: If the trailing asterisk is not used in the LSEARCH opt, then the specified library is a PDS:
#include "A.B"
LSEARCH('CC')
Result is 'CC(A)' which is a PDS.