Home Download Buy Blog Forum Support

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

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

Postby MrLavender on Sat Oct 06, 2012 2:14 pm

RyanJ wrote:
OnOff wrote:Clang analysis shows errors in headers mingw, but i compile the project with mingw32-g++ without errors or warnings.


My guess is missing include paths or a missing preprocessor define.

Yes. This is my experience after spending a couple of days fiddling with the plugin to get everything working, hope it helps someone.

Turning off the error limit (-ferror-limit=0) is helpful for debugging this kind of stuff.

To fix the winbase.h DECLSPEC_NORETURN error add the define __GNUC__=4

To fix "no member named 'fgetws' in the global namespace" etc in cwchar when using <string> add the define __MSVCRT__

Include paths will vary by MinGW distribution and/or version, this is what works for me using the 4.7.2 package from nuwen.net;

Code: Select all
  "options":
  [
    "-ferror-limit=0",
    "-D__GNUC__=4",
    "-D__MSVCRT__",
    "-isystem", "C:\\MinGW\\lib\\gcc\\i686-pc-mingw32\\4.7.2",
    "-isystem", "C:\\MinGW\\lib\\gcc\\i686-pc-mingw32\\4.7.2\\include",
    "-isystem", "C:\\MinGW\\lib\\gcc\\i686-pc-mingw32\\4.7.2\\include-fixed",
    "-isystem", "C:\\MinGW\\include",
    "-isystem", "C:\\MinGW\\include\\c++\\4.7.2",
    "-isystem", "C:\\MinGW\\include\\c++\\4.7.2\\i686-pc-mingw32",
    "-Wall"
  ]


Great plugin, thanks very much :)
MrLavender
 
Posts: 2
Joined: Sat Oct 06, 2012 1:54 pm

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

Postby MrLavender on Sat Oct 06, 2012 2:40 pm

And now a question. Is there any way to get the plugin to provide auto-complete parameters for functions defined as a macro?

E.g. In the windows headers any function that takes a string has two versions, which are selected based on whether UNICODE is defined or not;

Code: Select all
WINUSERAPI int WINAPI MessageBoxA(HWND,LPCSTR,LPCSTR,UINT);
WINUSERAPI int WINAPI MessageBoxW(HWND,LPCWSTR,LPCWSTR,UINT);

#ifdef UNICODE
#define MessageBox MessageBoxW
#else
#define MessageBox MessageBoxA
#endif

The auto-complete will show the MessageBox macro at the top of the list, but choosing it just enters MessageBox with no parameters. I have to go down the list and select MessageBoxA or MessageBoxW to get the parameters, which is a bit annoying.
MrLavender
 
Posts: 2
Joined: Sat Oct 06, 2012 1:54 pm

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

Postby JesseMeyer on Mon Nov 19, 2012 6:58 am

Hi guys.

First, thank you quarnster (and any other developer I'm not aware of) for this incredibly useful plugin.

I'm attempting to switch from VS to Sublime for all my C++ coding needs on Win7. I've successfully built my C++ code from within SLT2 using MSVC. The functionality I miss the most that's left to integrate is code competition / checking. I've been following this plugin for awhile and unfortunately I do not know enough to figure this one out. I've researched and have attempted numerous times but to no avail. Please help.

I'm writing a game and have my code separated into two directories under a single folder.

F:/Game/EngineCode
"" / "" /GameCode

My VS install is standard.

Whenever I open a game source file, clang freaks out claiming that it cannot find any includes. Here is my sublime options and project settings.

Code: Select all
{
   "folders":
   [
      {
         "path": "/F/C4-2.10/VisualStudio2012/C4"
      },
      {
         "path": "/F/C4-2.10/EngineCode"
      },
      {
         "path": "/F/C4-2.10/GameCode"
      }
   ],

   "settings":
   {
      "sublimeclang_options":
       [
           "-IF:/C4-2.10/EngineCode"
       ]
    }
}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Code: Select all
    "options":
    [
        "-isystem", "F:/C4-2.10/EngineCode",
        "-IF:/C4-2.10/GameCode",
        "-ferror-limit=0",
        "-Wall"
    ],


And for the strange part. In my game code, sometimes it will report the file locations with their directory slash reversed. It's not uncommon to see

F:\Game\GameCode/someFile.h:19,10 - Fatal - 'someInclude.h' file not found ("someInclude" is not ever in the same directory as "someFile").

If anyone would assist I'd be very grateful.

Thank you in advanced.

JM
JesseMeyer
 
Posts: 4
Joined: Thu Feb 09, 2012 10:55 pm

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

Postby Nova on Mon Nov 19, 2012 8:57 am

I absolutely love SublimeCLang!
One question: "sometimes", SublimeCLang slows down the whole ST2. I mean: on a project that is normally working fine... at some point in time using CLang blocks ST2 every time I press a letter, waiting for the autocomplete. This is due to Clang, since if I disable it, ("enabled": false) everything works
Sometimes, I also get messages from ST2 saying "A plugin clang is locking ST..." (or something similar).

I know my question is quite "vague", but I have no further details, nor ideas what to look for...

Thank you in advance for any help.
Nova
 
Posts: 19
Joined: Tue Jul 10, 2012 9:01 am

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

Postby rchl on Sun Dec 16, 2012 12:59 pm

1. I wonder if it's possible to use clang plugins with SublimeClang (or maybe question should be: is it possible to use plugins with libclang?). I can't get it to work after specifying appropriate arguments to clang. For example:
Code: Select all
-Xclang -load -Xclang ../BoolCheck.so -Xclang -add-plugin -Xclang boolcheck -Xclang -plugin-arg-boolcheck -Xclang -load-type-list -Xclang -plugin-arg-boolcheck -Xclang test-bools

as mentioned here: http://blog.mozilla.org/mwu/2011/07/28/ ... f-mozilla/ (note that I have not tried this specific plugin).

2. Connected to above, is it possible to configure SublimeClang to spew out all kind of output that clang would spew out? For example, if normal clang executable fails to load the plugin, it might say something in the standard output. With libclang I think it only outputs stuff it was asked for (or maybe it is filtered by SublimeClang?).
That could be also useful for seeing more detailed information about warnings or errors that standalone clang tends to produce.
rchl
 
Posts: 148
Joined: Fri Mar 04, 2011 11:02 pm

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

Postby amphetamine on Thu Dec 27, 2012 6:19 pm

SublimeClang works nicely on Windows with Visual C++ after adding the VC++ and Windows SDK include folders to the search path.

Excellent plugin! Thanks!
amphetamine
 
Posts: 23
Joined: Fri Dec 14, 2012 8:59 pm

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

Postby MrStorm on Thu Jan 17, 2013 10:37 am

Hi, is there a way to change brackets position when autocomplete is used? For example, when I use autocomplete for the if keyword I get
Code: Select all
if (/* condition */)
{
  /* code */
}

but I would prefer the following (default style in SublimeJava):
Code: Select all
if (/* condition */) {
  /* code */
}

Thanks for the help :)
MrStorm
 
Posts: 3
Joined: Thu Jan 17, 2013 10:32 am

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

Postby agibsonsw on Thu Jan 17, 2013 2:09 pm

I suspect this is just the default snippet, that you can amend:

Code: Select all
<snippet>
   <description>If Condition</description>
    <content><![CDATA[if (${1:/* condition */})
{
   ${0:/* code */}
}]]></content>
    <tabTrigger>if</tabTrigger>
    <scope>source.c, source.objc, source.c++, source.objc++</scope>
</snippet>


[in the C++ folder.]
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

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

Postby MrStorm on Fri Jan 18, 2013 11:12 am

It worked, thank you very much :)
MrStorm
 
Posts: 3
Joined: Thu Jan 17, 2013 10:32 am

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

Postby Kwelity on Sun Feb 17, 2013 11:41 am

Hi,

I have an issue with SublimeClang when using multiple cursors. Let me use an example :

Let say I have 4 functions

func1|
func2|
func3|
func4|

With for cursors at the end of the line.
if I hit space, the cursors will take a different position, shifting the positions to 1 character each line, like this

func1 |
func |2
fun |c3
fu |nc4

I only have this issue when Clang is enable.

So if anyone have an idea ...

Thank you.
Sorry for my english :)
Kwelity
 
Posts: 7
Joined: Fri Oct 05, 2012 8:50 am

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests