Function: ffap--c-path
ffap--c-path is a byte-compiled function defined in ffap.el.gz.
Signature
(ffap--c-path)
Documentation
Return search path for C header files (a list of strings).
Source Code
;; Defined in /usr/src/emacs/lisp/ffap.el.gz
(defun ffap--c-path ()
"Return search path for C header files (a list of strings)."
;; FIXME: It's not clear that this is a good place to put this, or
;; even that this should necessarily be internal.
;; See also (Bug#10702):
;; cc-search-directories, semantic-c-dependency-system-include-path,
;; semantic-gcc-setup
(delete-dups
;; We treat MS-Windows/MS-DOS specially, since there's no
;; widely-accepted canonical directory for C include files.
(let ((base (if (not (memq system-type '(windows-nt ms-dos)))
'("/usr/include" "/usr/local/include")))
(call-clang-p (or (ffap--gcc-is-clang-p)
(and (executable-find "clang")
(not (executable-find "gcc"))))))
(cond ((or call-clang-p
(memq system-type '(windows-nt ms-dos)))
;; This is either macOS, or MS-Windows/MS-DOS, or a system
;; with clang only.
(with-temp-buffer
(ignore-errors
(call-process (if call-clang-p "clang" "gcc")
nil t nil
"-v" "-E" "-"))
(goto-char (point-min))
(narrow-to-region
(save-excursion
(re-search-forward
"^#include <\\.\\.\\.> search starts here:\n" nil t)
(point))
(save-excursion
(re-search-forward "^End of search list.$" nil t)
(pos-bol)))
(while (search-forward "(framework directory)" nil t)
(delete-line))
;; "gcc -v" reports file names with many "..", so we
;; normalize it.
(or (mapcar #'expand-file-name
(append base
(split-string (buffer-substring-no-properties
(point-min) (point-max)))))
;; Fallback for when the compiler is not available.
(list (expand-file-name "/usr/include")
(expand-file-name "/usr/local/include")))))
;; Prefer GCC.
((let ((arch (with-temp-buffer
(when (eq 0 (ignore-errors
(call-process "gcc" nil '(t nil) nil
"-print-multiarch")))
(goto-char (point-min))
(buffer-substring (point) (line-end-position))))))
(if (zerop (length arch))
base
(append base (list (expand-file-name arch "/usr/include"))))))))))