yasuyuky / autocomplete-clang

https://atom.io/packages/autocomplete-clang
MIT License
112 stars 35 forks source link

.clang_complete does not work #21

Closed JMLX42 closed 5 years ago

JMLX42 commented 9 years ago

Hello,

this plugin looks awesome but I can't get it to work. Whenever I try to toggle the autocomplete, I can an error in the dev console:

Unexpected return code of clang command: 1 autocomplete-clang-view.coffee:141
<stdin>:20:10: fatal error: 'minko/Minko.hpp' file not found
#include "minko/Minko.hpp"
         ^
1 error generated.

So I tried setting up a .clang_complete file in my project root directory:

-I/home/promethe/Projects/minko-beta3/framework/include

But it doesn't change nothing. Yet in the plugin configuration if I set the exact same directory in the "Include Path" field, it works. My guess is the .clang_complete is not handled properly.

Any hint?

Regards,

JMLX42 commented 9 years ago

The problem is in clang-flags, the fix is here: https://github.com/Kev/clang-flags/issues/1

assemblical commented 9 years ago

I also don't get my user path to work in the .clang_complete file. Lets say I want to work with Qt

#include <QMainWindow> 

I add the following line into my project .clang_complete file:

-I/Volumes/development/lib/Qt/5.4/clang_64/lib/QtWidgets.framework/Versions/5/Headers

But I still get the error 'QMainWindow' file not found. However I don't get an error in the coffee script file.

dschwen commented 9 years ago

Works for me. The .clang_complete file is read for me. I confirmed this by setting a breakpoint in codeCompletionAt: in the result = .. line. Then inspect command + ' ' + args.join(' ') and try to run that command line (you'll see if your settings from .clang_complete are there).

assemblical commented 9 years ago

Yes the file is read, but it doesn't work. I also saw the error now: Unexpected return code of clang command: 1 Let's hope the promethe fix gets involved soon so we can use this plugin.

dschwen commented 9 years ago

There should be a clang error message further up in the console. We need this to figure out the actual problem.

assemblical commented 9 years ago

The developer console in atom doesn't show any clang errors further up.

autocomplete-clang-view.coffee:139 Unexpected return code of clang command: 1
autocomplete-clang-view.coffee:140 <stdin>:5:10: fatal error: 'QErrorMessage' file not found
#include "QErrorMessage"
         ^
1 error generated.

If I run the command directly in my command line:

 clang -fsyntax-only -xc++ -Xclang -code-completion-at=-:72:9 -std=c++11 -I. -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 -I/usr/local/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/usr/include -I/Volumes/developement/lib/Qt/5.4/clang_64/lib/QtCore.framework/Versions/5/Headers -I/Volumes/developement/lib/Qt/5.4/clang_64/lib/QtWidgets.framework/Versions/5/Headers -working-directory=/Volumes/development/projects/src/myproject -

I doesn't respond because of the last - If I remove it and add the input file argument by myself it says

fatal error: cannot locate code-completion file <stdin>
1 error generated.

The option "Ignore Clang Errors" didn't help unfortunately.

dschwen commented 9 years ago

Then don't remove the - but rather do

cat yourinputfile.cpp | clang -fsyntax-only -xc++ -Xclang -code-completion-at=-:72:9 ...

Clang seems to expect input via stdin...

assemblical commented 9 years ago
In file included from <stdin>:5:
In file included from /Volumes/development/lib/Qt/5.4/clang_64/lib/QtWidgets.framework/Versions/5/Headers/QErrorMessage:1:
/Volumes/development/lib/Qt/5.4/clang_64/lib/QtWidgets.framework/Versions/5/Headers/qerrormessage.h:37:10: fatal error:
      'QtWidgets/qdialog.h' file not found
#include <QtWidgets/qdialog.h>
         ^
1 error generated.

So it can't find the qdialog header, however it is in the include path. I doubt this is a clang problem as it is working with vim's YouCompleteMe plugin which is also using a clang completion engine.

dschwen commented 9 years ago

If you are running the command outside of atom, as discussed above it indicates this is not a package issue. I'm not familiar with qt anymore but I suggest you search real careful where the missing include file is really located and double check if the include path is correct. I don't see how this could possibly be an issue with the package.

assemblical commented 9 years ago

I copied the flags from my .clang_complete to my .ycm_extra_conf.py and the completion with YouCompleteMe in vim works like a charm. The only difference I can think of is that the additional generated flags differ somehow.

Kev commented 9 years ago

Has this been resolved by the recent changes to clang_flags?

ssfrr commented 9 years ago

I'm not seeing my .clang_complete working here either, but I'm not sure if it's the same issue. I don't see any errors in the console except that it can't find a header file (which my flags should fix). It doesn't seem to load settings from clang_complete, or from the atom.config actually. I'm guessing maybe these got lost in the recent migration to autocomplete-plus integration?

zlondrej commented 8 years ago

Loading .clang_complete actually works fine.

Still, I had a lot of troubles to make autocomplete-clang work, because I didn't add src directory neither into Include Paths field in atom nor into .clang_complete file.

It didn't cross my mind to look into console. After I saw the message I knew what the problem was.

fatal error: 'IEventListener.hpp' file not found
#include "IEventListener.hpp"

I think it would be appropriate to notify user about errors (not warnings).

uxdxdev commented 8 years ago

Can you explain how you included other header files so that autocomplete-clang could find them? So far I have used:

-I/home/mortond/projects/Helium/cocos2d/cocos

This directory contains a cocos2d.h file and is being picked up by autocomplete, BUT the header files inside this one are not being registered. Can I add the header file contents to the autocomplete with something like:

-I/home/mortond/projects/Helium/cocos2d/cocos/cocos2d.h

or

-include /home/mortond/projects/Helium/cocos2d/cocos/cocos2d.h

Any help explaining how I can add other framework header files to the autocomplete would be great.

engineeror commented 7 years ago

Yep autocomplete-clang still can't find headers.

Sunhick commented 7 years ago

Adding include dirs in .clang_complete still doesn't work for me.

jkuri commented 6 years ago

i had to restart atom to get it work.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.