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
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:
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: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:
The resulting file name isLSEARCH(DD:NEWLIB) #include "a.b(c)"
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.
- LIB([pds,...]) where each pds is
a partitioned data set name. They are searched in the same order
as they are specified.
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.
#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.
#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:
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:
- All the paths and slashes (slashes are replaced by periods)
- 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.
#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
#include "sub/fred.h"
#include "fred.inl"
LSEARCH(USER.+,'USERID.GENERAL.+')
The compiler uses the following search sequence to look for your include files:
- First, the compiler looks for
sub/fred.h
in this data set:USERID.USER.SUB.H(FRED)
- If that PDS member does not exist, the compiler looks in the data
set:
USERID.GENERAL.SUB.H(FRED)
- If that PDS member does not exist, the compiler looks in DD:USERLIB, and then checks the system header files.
- Next, the compiler looks for
fred.inl
in the data set:USERID.USER.INL(FRED)
- If that PDS member does not exist, the compiler will look in the
data set:
USERID.GENERAL.INL(FRED)
- 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.
#include "sub/fred.h"
and specify:
LSEARCH(/u/mike)
The
compiler looks for the include file /u/mike/sub/fred.h
.#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:
- The compiler looks for
fred.h
in/u/mike/fred.h
. - If that z/OS UNIX file does not exist,
the compiler looks in
./sub/fred.h
. - If that z/OS UNIX file does not exist, the compiler looks in the libraries specified on the USERLIB DD statement.
- If USERLIB DD is not allocated, the compiler follows the search order for system include files.
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:
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).
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 |
#include "A.B"
LSEARCH('CC')
Result is 'CC(A)'
which
is a PDS.