Using SEARCH and LSEARCH

When the file name in the #include directive is not in absolute form, the opts in SEARCH are used to find system include files and the opts in LSEARCH are used to find user include files. Each opt is a library path and its format determines if it is a z/OS® UNIX System Services path or a data set path:

Figure 1. Determining if the SEARCH/LSEARCH opt is a z/OS UNIX path
REQTEXT
Note:
  1. If opt is preceded by double slashes (//) and opt does not start with a slash (/), then this path is a data set path.
  2. If opt is preceded by double slashes (//) and opt starts with a slash (/), then this path is a z/OS UNIX path.
  3. If opt is not preceded by double slashes (//) and opt starts with a slash (/), then this path is a z/OS UNIX path.
  4. If opt is not preceded by double slashes (//), opt does not start with a slash (/) and NOOE is specified then this path is a data set path.

For example:

Example: When combining the library with the file name specified on the #include directive, it is the form of the library that determines how the include file name is to be transformed:
Options specified:

  NOOE LSEARCH(Z, /u/myincs, (*.h)=(LIB(mac1)))

Include Directive:

  #include "apath/afile.h"

Resulting fully qualified include names:

1. userid.Z(AFILE)  (Z is non-z/OS UNIX file so file name is treated
as non-z/OS UNIX file)
2. /u/myincs/apath/afile.h   (/u/myincs is z/OS UNIX file so
file name is treated as z/OS UNIX file)
3. userid.MAC1.H(AFILE)             (afile.h matches *.h)
 
Example: A z/OS UNIX path specified on a SEARCH or LSEARCH option only combines with the file name specified on an #include directive if the file name is not explicitly stated as being MVS™ only. A file name is explicitly stated as being MVS only if two slashes (//) precede it, and filename does not start with a slash (/).
Options specified:

  OE LSEARCH(/u/myincs, q, //w)

Include Directive:

  #include "//file.h"

Resulting fully qualified include names

 userid.W(FILE)
 

/u/myincs and q would not be combined with //file.h because both paths are z/OS UNIX paths and //file.h is explicitly MVS.

The order in which options on the LSEARCH or SEARCH option are specified is the order that is searched.

See LSEARCH | NOLSEARCH and SEARCH | NOSEARCH for more information on these compiler options.