Emacs里C++头文件的问题,有没有这样一种插件?

原问题是clang failed with error 1,不过这个不要紧了,原因见下。

  • 更新:这个错误和company-c-header没有关系,不过这个插件并没有起作用,设置如下:
(custom-set-variables
 '(company-backends
   (quote
    (company-bbdb company-nxml company-css company-eclim company-semantic company-clang company-xcode company-cmake company-capf company-files
                  (company-dabbrev-code company-gtags company-etags company-keywords)
                  company-oddmuse company-dabbrev company-c-headers))))
  • 更新2:有没有这样一种插件,不需要打tags,里文件里有一行#include <iostream>,就可以选择打开iostream这个文件,不需要找声明定义这些,只需要打开文件就行了。

這個庫調用 libclang 嗎?如果是 libclang ,1 代表:

https://github.com/llvm-mirror/clang/blob/master/include/clang-c/CXErrorCode.h#L41


/**
 * \brief Error codes returned by libclang routines.
 *
 * Zero (\c CXError_Success) is the only error code indicating success.  Other
 * error codes, including not yet assigned non-zero values, indicate errors.
 */
enum CXErrorCode {
.....

  /**
   * \brief A generic error code, no further details are available.
   *
   * Errors of this kind can get their own specific error codes in future
   * libclang versions.
   */
  CXError_Failure = 1,

並沒有更多信息。更多 diagnostics 要用 CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags); 等取出字串形式的 diagnostics

等一下,第一次用,才知道有个clang-error buffer

Sat Jan 13 16:54:16 2018
clang failed with error 1:
/usr/bin/clang -fsyntax-only -Xclang -code-completion-macros -x c++ -std=c++11 -Xclang -code-completion-at=-:2:9 -

<stdin>:2:9: error: expected "FILENAME" or <FILENAME>
#include<U+0000>
        ^
1 error generated.

看到了你的cquery感觉很不错,等会儿试一下。