Skip to content

Commit a907246

Browse files
authored
[Clang][Docs][NFC] Correct documentation for the CPATH environment variable (#129113)
Clang's prior documentation for the `CPATH` environment variable stated that paths it specifies are added as system header search paths. The actual behavior is that such paths are treated as though they were passed via `-I` options at the end of the driver command line and are thus added as non-system (user) header search paths. The documentation additionally claimed that empty path entries in the `CPATH` environment variable are ignored. This was also incorrect; Clang treats empty entries as nominating the compiler's current working directory; as though `.` was specified. Clang's behavior is consistent with gcc as documented at https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html#index-CPATH. This change aligns Clang's documentation with the behavior actually observed. Additional editorial changes are included to clarify that the related `C_INCLUDE_PATH`, `CPLUS_INCLUDE_PATH`, `OBJC_INCLUDE_PATH`, and `OBJCPLUS_INCLUDE_PATH` environment variables specify additional paths that are treated as system header search paths (in contrast to `CPATH`). Fixes issue #49742.
1 parent a24523a commit a907246

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

clang/docs/CommandGuide/clang.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -733,16 +733,19 @@ ENVIRONMENT
733733

734734
.. envvar:: CPATH
735735

736-
If this environment variable is present, it is treated as a delimited list of
737-
paths to be added to the default system include path list. The delimiter is
738-
the platform dependent delimiter, as used in the PATH environment variable.
739-
740-
Empty components in the environment variable are ignored.
736+
This environment variable specifies additional (non-system) header search
737+
paths to be used to find included header files. These paths are searched after
738+
paths specified with the :option:`-I\<directory\>` option, but before any
739+
system header search paths. Paths are delimited by the platform dependent
740+
delimiter as used in the ``PATH`` environment variable. Empty entries in the
741+
delimited path list, including those at the beginning or end of the list, are
742+
treated as specifying the compiler's current working directory.
741743

742744
.. envvar:: C_INCLUDE_PATH, OBJC_INCLUDE_PATH, CPLUS_INCLUDE_PATH, OBJCPLUS_INCLUDE_PATH
743745

744-
These environment variables specify additional paths, as for :envvar:`CPATH`, which are
745-
only used when processing the appropriate language.
746+
These environment variables specify additional system header file search
747+
paths to be used when processing the corresponding language. Search paths are
748+
delimited as for the :envvar:`CPATH` environment variable.
746749

747750
.. envvar:: MACOSX_DEPLOYMENT_TARGET
748751

0 commit comments

Comments
 (0)