Clang извлекает ненужные заголовки при использовании автозаполнения из различных IDE


2

Эта проблема может быть замечена, когда мы имеем дело с функцией автозаполнения данной IDE. Я заметил это поведение в текстовых редакторах, таких как: Xcode, Vim, VScode, Atom.

Плагины автозаполнения используют лязг для извлечения символов из включенных заголовков. Но проблема в том, что он предлагает мне функции C из заголовков, которые я никогда не включал.

Как видите, я даже не включил один заголовок. Но когда я включаю, например, iostream, он все равно дает мне кучу функций C из libs, как time.h

Я не знаю, почему Clang предоставляет множество других функций из C libs, когда его не просят.

Я установил только инструменты командной строки Xcode. ОС: High Sierra 10.13.4 (17E199)

user$ clang --version
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin


clang -cc1 version 9.1.0 (clang-902.0.39.1) default target x86_64-apple-darwin17.5.0
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/include
 /Library/Developer/CommandLineTools/usr/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.

Если мы посмотрим на зависимости main.cpp, то увидим следующее:

user$:Workspace artur$ clang main.cpp -M
main.o: main.cpp \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/iostream \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__config \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/ios \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/iosfwd \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/wchar.h \
  /usr/include/wchar.h /usr/include/_types.h /usr/include/sys/_types.h \
  /usr/include/sys/cdefs.h /usr/include/sys/_symbol_aliasing.h \
  /usr/include/sys/_posix_availability.h /usr/include/machine/_types.h \
  /usr/include/i386/_types.h /usr/include/sys/_pthread/_pthread_types.h \
  /usr/include/Availability.h /usr/include/AvailabilityInternal.h \
  /usr/include/sys/_types/_null.h /usr/include/sys/_types/_size_t.h \
  /usr/include/sys/_types/_mbstate_t.h /usr/include/machine/types.h \
  /usr/include/i386/types.h /usr/include/sys/_types/_int8_t.h \
  /usr/include/sys/_types/_int16_t.h /usr/include/sys/_types/_int32_t.h \
  /usr/include/sys/_types/_int64_t.h /usr/include/sys/_types/_u_int8_t.h \
  /usr/include/sys/_types/_u_int16_t.h \
  /usr/include/sys/_types/_u_int32_t.h \
  /usr/include/sys/_types/_u_int64_t.h \
  /usr/include/sys/_types/_intptr_t.h \
  /usr/include/sys/_types/_uintptr_t.h \
  /usr/include/sys/_types/_ct_rune_t.h /usr/include/sys/_types/_rune_t.h \
  /usr/include/sys/_types/_wchar_t.h \
  /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/include/stdarg.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdio.h \
  /usr/include/stdio.h /usr/include/_stdio.h \
  /usr/include/sys/_types/_va_list.h /usr/include/sys/stdio.h \
  /usr/include/sys/_types/_off_t.h /usr/include/sys/_types/_ssize_t.h \
  /usr/include/time.h /usr/include/sys/_types/_clock_t.h \
  /usr/include/sys/_types/_time_t.h /usr/include/sys/_types/_timespec.h \
  /usr/include/_wctype.h /usr/include/__wctype.h \
  /usr/include/sys/_types/_wint_t.h /usr/include/_types/_wctype_t.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/ctype.h \
  /usr/include/ctype.h /usr/include/_ctype.h /usr/include/runetype.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__locale \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string_view \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__string \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/initializer_list \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef \
  /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/include/stddef.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__nullptr \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cstring \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/string.h \
  /usr/include/string.h /usr/include/sys/_types/_rsize_t.h \
  /usr/include/sys/_types/_errno_t.h /usr/include/strings.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/utility \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__tuple \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdint \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdint.h \
  /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/include/stdint.h \
  /usr/include/stdint.h /usr/include/_types/_uint8_t.h \
  /usr/include/_types/_uint16_t.h /usr/include/_types/_uint32_t.h \
  /usr/include/_types/_uint64_t.h /usr/include/_types/_intmax_t.h \
  /usr/include/_types/_uintmax_t.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/memory \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/typeinfo \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/exception \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdlib \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h \
  /usr/include/stdlib.h /usr/include/sys/wait.h \
  /usr/include/sys/_types/_pid_t.h /usr/include/sys/_types/_id_t.h \
  /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h \
  /usr/include/machine/signal.h /usr/include/i386/signal.h \
  /usr/include/machine/_mcontext.h /usr/include/i386/_mcontext.h \
  /usr/include/mach/machine/_structs.h /usr/include/mach/i386/_structs.h \
  /usr/include/sys/_pthread/_pthread_attr_t.h \
  /usr/include/sys/_types/_sigaltstack.h \
  /usr/include/sys/_types/_ucontext.h \
  /usr/include/sys/_types/_sigset_t.h /usr/include/sys/_types/_uid_t.h \
  /usr/include/sys/resource.h /usr/include/sys/_types/_timeval.h \
  /usr/include/machine/endian.h /usr/include/i386/endian.h \
  /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \
  /usr/include/libkern/i386/_OSByteOrder.h /usr/include/alloca.h \
  /usr/include/sys/_types/_dev_t.h /usr/include/sys/_types/_mode_t.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/new \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/limits \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__undef_macros \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/iterator \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__functional_base \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__functional_base_03 \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/tuple \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/stdexcept \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cassert \
  /usr/include/assert.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/atomic \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdio \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cwchar \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cwctype \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cctype \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/wctype.h \
  /usr/include/wctype.h /usr/include/_types/_wctrans_t.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/mutex \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__mutex_base \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/chrono \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/ctime \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/ratio \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/climits \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/limits.h \
  /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/include/limits.h \
  /usr/include/limits.h /usr/include/machine/limits.h \
  /usr/include/i386/limits.h /usr/include/i386/_limits.h \
  /usr/include/sys/syslimits.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/system_error \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/cerrno \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/errno.h \
  /usr/include/errno.h /usr/include/sys/errno.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__threading_support \
  /usr/include/pthread.h /usr/include/pthread/pthread_impl.h \
  /usr/include/pthread/sched.h \
  /usr/include/sys/_pthread/_pthread_cond_t.h \
  /usr/include/sys/_pthread/_pthread_condattr_t.h \
  /usr/include/sys/_pthread/_pthread_key_t.h \
  /usr/include/sys/_pthread/_pthread_mutex_t.h \
  /usr/include/sys/_pthread/_pthread_mutexattr_t.h \
  /usr/include/sys/_pthread/_pthread_once_t.h \
  /usr/include/sys/_pthread/_pthread_rwlock_t.h \
  /usr/include/sys/_pthread/_pthread_rwlockattr_t.h \
  /usr/include/sys/_pthread/_pthread_t.h /usr/include/pthread/qos.h \
  /usr/include/sys/qos.h /usr/include/sys/_types/_mach_port_t.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/functional \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__functional_03 \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/locale.h \
  /usr/include/locale.h /usr/include/_locale.h /usr/include/xlocale.h \
  /usr/include/_xlocale.h /usr/include/xlocale/_ctype.h \
  /usr/include/xlocale/__wctype.h /usr/include/xlocale/_stdio.h \
  /usr/include/xlocale/_stdlib.h /usr/include/xlocale/_string.h \
  /usr/include/xlocale/_time.h /usr/include/xlocale/_wchar.h \
  /usr/include/xlocale/_wctype.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/streambuf \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/istream \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/ostream \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/locale \
  /usr/include/nl_types.h /usr/include/sys/types.h \
  /usr/include/sys/_types/_u_char.h /usr/include/sys/_types/_u_short.h \
  /usr/include/sys/_types/_u_int.h /usr/include/sys/_types/_caddr_t.h \
  /usr/include/sys/_types/_blkcnt_t.h \
  /usr/include/sys/_types/_blksize_t.h /usr/include/sys/_types/_gid_t.h \
  /usr/include/sys/_types/_in_addr_t.h \
  /usr/include/sys/_types/_in_port_t.h /usr/include/sys/_types/_ino_t.h \
  /usr/include/sys/_types/_ino64_t.h /usr/include/sys/_types/_key_t.h \
  /usr/include/sys/_types/_nlink_t.h \
  /usr/include/sys/_types/_useconds_t.h \
  /usr/include/sys/_types/_suseconds_t.h \
  /usr/include/sys/_types/_fd_def.h \
  /usr/include/sys/_types/_fd_setsize.h \
  /usr/include/sys/_types/_fd_set.h /usr/include/sys/_types/_fd_clr.h \
  /usr/include/sys/_types/_fd_zero.h /usr/include/sys/_types/_fd_isset.h \
  /usr/include/sys/_types/_fd_copy.h \
  /usr/include/sys/_types/_fsblkcnt_t.h \
  /usr/include/sys/_types/_fsfilcnt_t.h /usr/include/_types/_nl_item.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__bsd_locale_defaults.h \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/bitset \
  /Library/Developer/CommandLineTools/usr/include/c++/v1/__bit_reference
Используя наш сайт, вы подтверждаете, что прочитали и поняли нашу Политику в отношении файлов cookie и Политику конфиденциальности.
Licensed under cc by-sa 3.0 with attribution required.