Sublime Forum

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

#15

Until someone contributes a 64-bit libclang.dll, youā€™ll have to make do with using the 32 bit Sublime Text 2 if you want to use this plugin.

0 Likes

#16

Yeah I thought this was the case. I did manage to build libclang in 64 mode for windows. However, now I get these when itā€™s trying to autocomplete on -> or ::

Perhaps thereā€™s an issue with how I built itā€¦

Traceback (most recent call last):
  File ".\sublime_plugin.py", line 175, in on_query_completions
  File ".\sublimeclang.py", line 596, in on_query_completions
  File ".\clang\cindex.py", line 1568, in codeComplete
WindowsError: exception: access violation writing 0x00000000000C0000
Traceback (most recent call last):
  File ".\sublimeclang.py", line 175, in worker
  File ".\clang\cindex.py", line 1546, in reparse
WindowsError: exception: access violation writing 0x0000000004EC0000

Hereā€™s my libclang (x64, compiled using vc2010).
ttvd.org/temp/libclang_x64_vc2010.rar

Thanks!

0 Likes

#17

Are you working with huge files or is there any other reason you must use the 64-bit executable of Sublime Text 2?

0 Likes

#18

Hi,
I got it working on Arch Linux.
You have to add the header search path /usr/lib/clang/3.0/include to SublimeClangā€™s config. If your distribution doesnā€™t have clang 3.0 yet, you can find those headers in clang-3.0.src/lib/Headers of llvm.org/releases/3.0/clang-3.0.tar.gz

Thanks for your work, quarnster!

0 Likes

#19

Wowā€¦ this is utterly mind blowing even in its early state. My vote for best pluginā€¦ever?

I would have killed for the equivalent of visual studioā€™s f12, and now i have it, plus really good code completion that just works (still a bit rough, but its great still)ā€¦ props to you quarnster.

Edit: To help other newbies, to get the most out of it I had to change my options and add them to the User version of SublimeClang.sublime-settings like so: (on mac os lion, will try win 7 64 bit eventually)

"options":
	    
	        "-Wall",
	        "-std=c++11",
	        "-I/usr/lib/clang/3.0/include/",
	        "-I/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1",
	        "-I/Users/alanandersen/dev"
	    ]

Also, it seems once you install Xcode 4.2, all the gcc stuff is moved from /usr/ into /Developer, took a bit to figure that outā€¦

0 Likes

#20

Cheers for the props guys :smile:

Please let me know if you have any specific requests or suggestions for making it better. Pull requests with new features are welcome.

0 Likes

#21

Hi, sorry for the newbyness but, on windows, how do you specify the include path ? It seems to never find my standard c includes.

[quote]Z:\local\pegasusmanager\LIBPEGASUSMANAGER_01_00_00\bins\fpgaconfig\fpgaconfig.c:15,10 - Fatal - ā€˜stdint.hā€™ file not found
Did you configure the include path used by clang properly?
See github.com/quarnster/SublimeClang for more details on how to configure SublimeClang.
[/quote]

Thanks a lot :smile:

0 Likes

#22

You need to open up the SublimeClang settings and tweak the ā€œoptionsā€ list by adding ā€œ-IC:/wherever/your/include/files/areā€. A good start would be to search for stdint.h. Please let me know what path it resides in on your Windows installation and Iā€™ll add it as a default path.

0 Likes

#23

No i do not work with large files, but I found that x64 version of sublime is faster on my machine than x32 for w/e reason. Do you have any suggestion as to what might be the problem with my x64 libclang ?

Thanks.

0 Likes

#24

No idea what the problem might be, but you could try this simple C++ sample and see if that works to isolate whether itā€™s your libclang.dll or something with the python bindings thatā€™s broken. Please do let me know if you figure it out.

0 Likes

#25

Well the file is there : c:\MinGW\include

And none of those work:

    "options":
    
        "-Wall",
        "-I/C/MinGW/include",
        "-IC/MinGW/include",
        "-IC:/MinGW/include"
    ]
0 Likes

#26

Actually, looks like youā€™ve found a bug in Sublime Text.

Please upgrade the plugin to the latest version just submitted that has a fix for this or move the options to your SublimeClang user settings. ā€œ-IC:/MinGW/includeā€ should work just fine and is now added to the default include paths. Please let me know if this fixes the issue or if youā€™re still having problems. Thanks.

0 Likes

#27

BTW, you probably want to edit the SublimeClang user settings anyway as the default settings might be overwritten when the plugin is updated.

0 Likes

#28

It works thanks.

Iā€™ll edit my user settings as you suggested.

0 Likes

#29

This is awesome. Love this. Iā€™ve gotten a fairly complex C++ project, and most things are now working for me.

One thing that doesnā€™t seem to work for me, is the ctrl-d ctrl-i to jump to the definition. It displays ā€œDonā€™t know where the implementation is!ā€ on the sublime status line. Iā€™ve peeked at the Python code for the error, but not sure where the problem is or how to debug the python.

Iā€™ve tried with a simple test: myutil.h and myutil.c that exist in the same directory. Iā€™ve also made sure that Iā€™ve got a -I to the same directory that holds myutil.h in the SublimeClang.sublime-settings file. Iā€™m on Mac OS X Lion.

.c file is like:
#include <myutil.h>

int myFunc(int a, int b, double c) {
return a + b;
}

and .h file just has:
int myFunc(int a, int b, double c);

Any ideas?

Thanks again for the excellent work!

0 Likes

#30

Try updating the plugin now, it should be fixed in the latest version in git.

Thanks for reporting this and please let me know if it now works or if itā€™s still broken :smile:

0 Likes

#31

That fixed it, thanks for the fast turn around.

0 Likes

#32

Is there a way to configure this to autocomplete OS X and iOS frameworks and autocomplete Objective-C properly?

Unfortunately I canā€™t get the frameworks to autocomplete just by adding an include path since Frameworkā€™s are structured Name.framework/Headers/.h
But they are included as <Name/file.h>.

0 Likes

#33

Is there a way to get per-project settings for plugins like this?

I ask because I work on a lot of embedded projects, where the system headers are not useful, and what you frequently want is project-relative headers plus headers from . Many (most) RTOSā€™ have headers whose names collide with the names of system headers, so you canā€™t just bulk out the include path.

0 Likes

#34

joh, Try adding something like this to your clang options:

        "-isysroot",
        "/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk",
        "-D__IPHONE_OS_VERSION_MIN_REQUIRED=40300",

I donā€™t code in Objective-C/Objective-C++ myself, so while I believe basic support is there Iā€™m sure it could be improved. Pull requests with more fleshed out support would be more than welcome :smile:

MikeSmith, No idea regarding per-project settings, please do let me know if you figure it out.

0 Likes