Home Download Buy Blog Forum Support

clang (C/C++/Objective-C/Objective-C++) autocomplete

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby kartynnik on Tue Feb 14, 2012 11:48 am

I'm very thankful to the author of this excellent plugin! I'd add the following to the list of suggestions:
  • When a header with
    Code: Select all
    #pragma once
    is analyzed, clang emits a warning
    Code: Select all
    #pragma once in main file
    As I can reason after skimming through the sources of clang, that warning can't be disabled per se, only with -w and the like, which can obviously be an overkill. Maybe the plugin could filter out such warnings when analyzing headers (or any sources, really, it wouldn't harm).
  • Don't know if that's possible, but it would be great if the clang output window doesn't pop out during the build, thus preventing to see whether the build was successful.
kartynnik
 
Posts: 1
Joined: Tue Feb 14, 2012 11:31 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby Shirk on Wed Feb 22, 2012 6:59 am

Is it possible that the "new" autocompletion present in the recent build will interfere with SublimeClang?

I was able to configure one of my smaler projects to generate a valid cache and I (sometimes) have completion
but along the clang-completion there seems to be the normal autocomplete list. In some cases this seems to
go as far as completely replacing the clang completions (you can distinguish them by the type-signature in the completion).

I really think this plugin is a great idea - I've been using something similar on vim for quiet some time now.

One other thing I notice is that SublimeClang sometimes - without a reason - claims no to find a header it was
finding five minutes ago without any problems. Is there any way (or line of code) I can use to get the plugin to
display what it is passing to clang so I can check if my paths are configured correctly?

P.S. I'm able to test against linux / osx clang (3.1)
Shirk
 
Posts: 5
Joined: Wed Feb 22, 2012 6:52 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby Tsurara on Thu Feb 23, 2012 7:08 am

mnus wrote:Regarding Linux errors

I'm running Ubuntu 11.10 64bit. I was able to get this plugin working by symlinking /usr/lib/python2.6/ to sublime2's lib directory, and recompiling libclang.so to target a 64bit architecture.

1.) Install python2.6 via apt-get or synpactic.
2.) Backup python26.zip in sublime2's lib directory (just for safe measure). I did mv "python26.zip backup.python26.zip"
3.) Symlink /usr/lib/python2.6/ to sublime2's lib directory.
4.) Download and compile clang. (You can probably get away with installing clang from the ubuntu repos)
5.) Copy libclang.so from the installed location into /.config/sublime-text-2/Packages/SublimeClang/

I'm still left with the issue of Clang not being able to find "stdarg.h", but I believe that's a clang bug and has nothing to do with this plugin.

Note to the the author of this plugin: It's probably best not to include the compiled library for linux in your repository, given that each architecture requires its own build. It may be a better idea just to have a text file instructing linux users to build and copy libclang themselves. Thanks for this awesome plugin!


I'm using openSUSE 12.1 with python2.7. And I did the symlink by running the command:
Code: Select all
# ln -s /usr/lib/python2.7/ /usr/share/SublimeText2/lib/

It did work for the plugin, as the "ctypes" error message no longer appear.
However, other problems arose after I've done the linkage. When I start st2 from Konsole(/usr/share/SublimeText2/sublime_text), an error message is shown in the Konsole:
Code: Select all
'import site' failed; use -v for traceback

while the st2 is still able to run.
And the terminal inside st2 shows much more error messages:
Code: Select all
Traceback (most recent call last):
  File "./sublime_plugin.py", line 1, in <module>
    import os
ImportError: No module named os
plugin init time: 0.116299
loading bindings
loading pointer bindings
found 1 files for base name Default.sublime-theme
theme loaded
app ready
pre session restore time: 0.213486
using gamma: 1 (err: 0)
AttributeError: 'module' object has no attribute 'on_activated'

The Clang did not work well once I did the linkage, and it's the same when I did the linkage to python2.6 in another folder. So the solution seems dose not work at my laptop.
Hope the problem could be solved in next update~
Tsurara
 
Posts: 1
Joined: Thu Feb 23, 2012 4:49 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby sujz on Mon Feb 27, 2012 8:52 am

Try to use "//" or "\\" instead of "\" for Windows.

tiktaalik wrote:
quarnster wrote:Try removing the first "/" before D:



Tried this but didn't have an effect. Currently looks like so:

Code: Select all
"-ID:/blah/MadScience/Project/blahproj/dev/Package/",
"-ID:/blah/MadScience/Project/blahproj/dev/Source/"
sujz
 
Posts: 1
Joined: Mon Feb 27, 2012 5:39 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby magey on Thu Mar 08, 2012 11:47 am

There seems to be a problem with the latest build of Sublime Text (2181) and this plugin. Per-project settings don't work at all and the Sublimeclang error pane makes the caret disappear and re-appear every time you move it while the pane is visible. Downgrading to 2165 resolves these issues.
magey
 
Posts: 4
Joined: Sun Jan 08, 2012 10:42 am

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby adn on Fri Mar 16, 2012 9:37 pm

Under Windows to autocomplete filenames in my 'include' directories (like stdio.h) I've added these lines to my 'SublimeClang.sublime-settings' file (in "options" section) as below:

"options":
[
....
.
.
.

//include path for minGW
,"-IC:\\Program Files\\MinGW\\include"
,"-IC:\\Program Files\\MinGW\\lib\\gcc\\mingw32\\4.6.1\\include"
],

Nice coding!
(I've typed commas first to know which line is added to the file and to remove just the lines if needed)
P.S. Your 'SublimeClang.sublime-settings' file is in '%Appdata%\Sublime Text 2\Packages\SublimeClang' folder.
adn
 
Posts: 5
Joined: Mon Mar 05, 2012 8:35 pm

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby Fidde on Tue Apr 03, 2012 1:56 am

sujz wrote:Try to use "//" or "\\" instead of "\" for Windows.

tiktaalik wrote:
quarnster wrote:Try removing the first "/" before D:



Tried this but didn't have an effect. Currently looks like so:

Code: Select all
"-ID:/blah/MadScience/Project/blahproj/dev/Package/",
"-ID:/blah/MadScience/Project/blahproj/dev/Source/"


On Windows I have found that you should not have a trailing '/' in the path. Additionally I tend to use '\\' instead of '/' because '\' is the native character on Windows for file separation (and because its an escape character you need two of them).
Fidde
 
Posts: 4
Joined: Fri Mar 30, 2012 7:25 pm

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby MikeSmith on Mon Apr 16, 2012 11:10 pm

quarnster wrote:MikeSmith and freewizard, Per project settings is now possible. See here and here for more details


I thought I'd replied previously but it looks otherwise - thank you for adding this feature, it is proving to be very useful.
MikeSmith
 
Posts: 2
Joined: Sat Jan 07, 2012 7:53 pm

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby dikamilo on Tue May 01, 2012 4:31 pm

adn wrote:Under Windows to autocomplete filenames in my 'include' directories (like stdio.h) I've added these lines to my 'SublimeClang.sublime-settings' file (in "options" section) as below:

"options":
[
....
.
.
.

//include path for minGW
,"-IC:\\Program Files\\MinGW\\include"
,"-IC:\\Program Files\\MinGW\\lib\\gcc\\mingw32\\4.6.1\\include"
],

Nice coding!
(I've typed commas first to know which line is added to the file and to remove just the lines if needed)
P.S. Your 'SublimeClang.sublime-settings' file is in '%Appdata%\Sublime Text 2\Packages\SublimeClang' folder.


This works for me very well but I get a lot of errors from mingw files like this:
http://img651.imageshack.us/img651/3976 ... 181953.png

Any solution to fix/disable this ?

Temporarily i set show_output_panel to false to disable this annoying errors.

My options:
Code: Select all
  "options":
  [
    "-Wall",
    "-Wextra",
    "-ferror-limit=0",
    "-IE:/Dev/Tools/MinGW64/include",
    "-IE:/Dev/Tools/MinGW64/lib/gcc/x86_64-w64-mingw32/4.6.1/include",
    "-IE:/Dev/Libs/gmock-1.6.0/include",
    "-IE:/Dev/Libs/gmock-1.6.0/gtest/include",
    "-IE:/Dev/Libs/glfw-2.7.2/include",
    // projects paths here
  ]
dikamilo
 
Posts: 2
Joined: Sun Apr 29, 2012 12:23 pm

Re: clang (C/C++/Objective-C/Objective-C++) autocomplete

Postby chc on Sun May 06, 2012 10:59 am

First of all, thanks for a great plugin!

I have stumbled upon a very annoying problem, that forces me to disable auto completion. :cry:

The problem I have is that auto completion does not seem to understand anonymous unions.
The library i'm trying to use has a struct that contains a type and a union with type dependent data.
The problem is that the type will always be auto completed (like there was no other members in the struct).
This makes it impossible to write code to access the members within the union.

I supply a minimal code example that can reproduce the problem.

Code: Select all
struct MyStruct
{
   int type;
   union
   {
      int value_int;
      double value_double;
   };
};

int main(int argc, char const *argv[])
{
   struct MyStruct my_struct;

   // try to use my_struct here with autocompletion enabled.
   // type is always auto completed and it is impossible
   // to write code to access value_int or value_double with auto complete enabled.

   return 0;
}
chc
 
Posts: 2
Joined: Sun May 06, 2012 10:42 am

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 5 guests