Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

用clang补全时出错 #34

Closed
ghost opened this issue Jul 27, 2013 · 13 comments
Closed

用clang补全时出错 #34

ghost opened this issue Jul 27, 2013 · 13 comments

Comments

@ghost
Copy link

ghost commented Jul 27, 2013

用clang补全时
clang failed with error 1:
/usr/bin/clang-cc1 -fsyntax-only -code-completion-macros -x c++ -code-completion-at -:7:10 -
但clang我自己用的时候没有error 1 的问题,求助大神呀喵

@redguardtoo
Copy link
Owner

Version of plugins

@ghost
Copy link
Author

ghost commented Jul 30, 2013

auto-complete-clang的版本时20120612,我下了个20120730版本的,把auto-complete-clang.el替换了,但是不行,我是个emacs新手,求指点呀

@hongxuchen
Copy link

@baby-bear 看看*clang error* buffer的头几行报什么错吧:-)

@ghost
Copy link
Author

ghost commented Jul 31, 2013

我感觉是clang-cc1的问题,首先好像没空格,而且编译c++一般好像用clang++,之后我把auto-complete-clang.el中一行 (append '("-cc1" " -fsyntax-only") 改成了 (append '("++ -cc1" " -fsyntax-only") 之后byte-compile-d,可还是不行.出现的错误都一样,而且minibuffer在开始只有一个build目录找不到的小错

@hongxuchen
Copy link

@baby-bear clang的介绍页面是这样说的

Note, the -cc1 argument indicates the compiler front-end, and not the driver, should be run.

@brianjcj 原来的elisp上出错信息写得很不好,你如果信得过的话试试我这个吧https://github.com/HongxuChen/dotfiles/blob/master/_emacs.d/site-lisp/auto-complete-clang/auto-complete-clang.el ,出错的话就看echo area或者/tmp/ac-clang-stderr文件

不过我觉得auto-complete-clang响应时间上不行,所以基本上放弃了

@redguardtoo
Copy link
Owner

use company-clang instead. I don't use auto-complete any more.

@redguardtoo
Copy link
Owner

I will see to the auto-complete issue this weekend. besides, you know to make auto-complete-clang work in real project, you need manual set up, right?

I created another project cpputils-cmake to do that set up.

if you don't use cmake and cpputils-cmake, you need set upac-clang-flags by yourself.

In one of my project, the value of ac-clang-flags is:
("-I/home/cb/wxWidgets-master/build-release/lib/wx/include/gtk2-unicode-static-2.9" "-I/home/cb/wxWidgets-master/include" "-I/home/cb/projs/dumbway/src/desktop/lua-5.2.1/src" "-I/usr/include/gtk-2.0" "-I/usr/lib64/gtk-2.0/include" "-I/usr/include/atk-1.0" "-I/usr/include/cairo" "-I/usr/include/gdk-pixbuf-2.0" "-I/usr/include/pango-1.0" "-I/usr/include/glib-2.0" "-I/usr/lib64/glib-2.0/include" "-I/usr/include/pixman-1" "-I/usr/include/freetype2" "-I/usr/include/libpng15")

@hongxuchen
Copy link

@redguardtoo auto-complete-clang sucks a lot since it uses vanilla clang --code-completion-at and cannot work well for larger projects(the flags issue is a permant headache, neither directory variables nor file local variables work well); there is also a problem with it: you cannot complete the function arguments when you are in template snippets stats. I remembered that the author referenced a lot of code from company-clang beforehand, which might be superior. But I think irony-mode and rtags are more suitable for C++ development. I hope you can have a try and share some customizations:-)

@redguardtoo
Copy link
Owner

cool, definitely I will try irony-mode

@notzhan
Copy link

notzhan commented Aug 1, 2013

恩,在编辑 .C 文件的时候,当想输入 struct test_stru 来定义一个结构体的时候, 输入到 struct tes 这个位置之后,就会出现这样的错误 /usr/bin/clang-cc1 -fsyntax-only -code-completion-macros -x c -code-completion-at -:2:12 - , clang error buffer 中的内容如下

clang failed with error 1:
/usr/bin/clang-cc1 -fsyntax-only -code-completion-macros -x c -code-completion-at -:5:12 -

<stdin>:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^
1 error generated.

如果已经定义了这个结构体,就不会出现这样的错误。

@redguardtoo
Copy link
Owner

C-h v, check ac-clang-flags.

@notzhan
Copy link

notzhan commented Aug 1, 2013

应该是在 init.el 中使用了 company-mode 而不是 auto-complete 的原因。

@redguardtoo
Copy link
Owner

what's your auto-complete plugin?

On Thu, Aug 1, 2013 at 4:26 PM, Imtxc notifications@github.com wrote:

I don't have variable name called ac-clang-flags in Debian sid amd64
Emacs24.3 and Clang 3.2-10


Reply to this email directly or view it on GitHubhttps://github.com//issues/34#issuecomment-21917228
.

help me, help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants