Home Download Buy Blog Forum Support

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


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

Postby rchl on Tue Apr 16, 2013 8:30 pm

With:
Code: Select all
int main(int argc, char const* argv[]) {
  int aaaaa = 0;
  int aaaaa = 0
  return 0;
}

select both aaaaa's (with ctrl+d) and press space. Weird things happen. I'm reporting this here as project is closed for issues. I guess I will probably try to fix it myself eventually but there is probably steep learning curve when it comes to the plugin's code.
rchl
 
Posts: 148
Joined: Fri Mar 04, 2011 11:02 pm

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

Postby AlexXsWx on Sun Apr 28, 2013 10:58 pm

I'm new to sublime, and trying to configure SublimeClang package. I've wrote opengl c++ program and made it work by compiling manually in console with a single line (using mingw-g++), but clang fails with alot of an odd errors in VS headers, which I didn't even included anywhere.
Here's list of all my includes in my working code:
Code: Select all
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/freeglut.h>


Here's my user-settings for SublimeClang package:
Code: Select all
{
   // I was trying to remove clang's default headers to fix this
   "dont_prepend_clang_includes": true,

   // I was trying to make it analyze in different way, but not sure if that's correct. Anyway it didn't made any visible difference
   //"analyzer_commandline":
   //[
   //    "g++",
   //    "-S",
   //    "-" // and what does this means?
   //],

   "options": ["-IC:\\MinGW\\include\\"],
   "debug_options": true
}


Here's the clang's output I keep getting:
Code: Select all
:0,0 - Fatal - too many errors emitted, stopping now [Disable with -ferror-limit=0]
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\cmath:37,13 - Error - no member named 'abs' in the global namespace
C:/MinGW/include\stdio.h:154,21 - Error - definition of variable with array type needs an explicit size or an initializer
C:/MinGW/include\stdlib.h:196,22 - Error - definition of variable with array type needs an explicit size or an initializer
C:/MinGW/include\wctype.h:99,33 - Error - definition of variable with array type needs an explicit size or an initializer
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\cwchar:25,52 - Error - no member named 'fgetws' in the global namespace
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\cwchar:26,13 - Error - no member named 'fputws' in the global namespace
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\cwchar:27,34 - Error - no member named 'getwc' in the global namespace
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\cwchar:27,53 - Error - no member named 'getwchar' in the global namespace
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\cwchar:29,34 - Error - no member named 'putwc' in the global namespace
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\cwchar:29,53 - Error - no member named 'putwchar' in the global namespace
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\iosfwd:310,3 - Error - no member named 'wmemcpy_s' in the global namespace
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\iosfwd:407,3 - Error - no member named 'wmemcpy_s' in the global namespace
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\iosfwd:504,3 - Error - no member named 'memcpy_s' in the global namespace
C:/MinGW/include\ctype.h:112,33 - Error - redefinition of '_ctype'
C:/MinGW/include\ctype.h:112,33 - Error - definition of variable with array type needs an explicit size or an initializer
C:/MinGW/include\ctype.h:117,34 - Error - redefinition of '_pctype_dll'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\system_error:23,33 - Error - use of undeclared identifier 'EAFNOSUPPORT'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\system_error:24,19 - Error - use of undeclared identifier 'EADDRINUSE'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\system_error:25,26 - Error - use of undeclared identifier 'EADDRNOTAVAIL'
:0,0 - Fatal - too many errors emitted, stopping now [Disable with -ferror-limit=0]


So why it keep try including that headers? Where it even found their location anyway? It isn't written in %path% or anywhere in sublime settings...

Sorry if this thread isn't the right place to ask this question, just idk where it is.
AlexXsWx
 
Posts: 2
Joined: Sun Apr 28, 2013 10:38 pm

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

Postby rchl on Mon Apr 29, 2013 11:11 pm

Clang will try (and usually succeed) to find the MS SDK if you have it installed. It won't work properly with it but that doesn't mean you have to prevent it from finding it. Just make sure that you specify MinGW includes so that these are found first.

For example I have these clang options specified which give quite good results*:
Code: Select all
"-Wall",
"-Werror",
"-Wextra",
"-Wnewline-eof",
"-Wendif-labels",
"-Wno-unused-parameter",
"-Wno-missing-field-initializers",
"-Wno-char-subscripts",
"-Wno-unused-function",
"-Wno-unnamed-type-template-args",
"-Wno-c++11-extensions",
"-Wno-covered-switch-default",
"-Wno-unknown-pragmas",
"-Wno-microsoft",
"-O0",
"-g",
"-gdwarf-2",
"-ferror-limit=0",
"-fmsc-version=1600",
"-fno-rtti",
"-fno-exceptions",
"-fvisibility-inlines-hidden",
"-fno-threadsafe-statics",
"-fcolor-diagnostics",
"-fno-strict-aliasing",
"-fstack-protector-all",
"-fsyntax-only",
"-std=c++11",
"-fgnu-runtime",
"-m32",
"-IC:/MinGW/lib/gcc/mingw32/4.7.2/include",
"-IC:/MinGW/lib/gcc/mingw32/4.7.2/include/c++",
"-IC:/MinGW/lib/gcc/mingw32/4.7.2/include/c++/mingw32",
"-IC:/MinGW/lib/gcc/mingw32/4.7.2/include/c++/backward",
"-IC:/MinGW/include"

Some options might be specific to the code base I'm working on but it's mostly about "-I" options that make things work. Just download MinGW and fed it to clang.

*By "quite good results" I mean that I will see errors highlighted inline in the source. But don't try to look at the error console (alt+d, alt+p) because there will *always* be many errors there. I guess because MinGW headers are not fully compatible with clang.
rchl
 
Posts: 148
Joined: Fri Mar 04, 2011 11:02 pm

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

Postby AlexXsWx on Tue Apr 30, 2013 10:19 am

Thanks, I didn't checked if it's working. Just thought it doesn't, as I've seen alot of errors.
Now it properly highlights errors in my code and makes correct suggestions for autocomplete. Still, I'm having alot of errors in VS headers, but I'll ignore that.
AlexXsWx
 
Posts: 2
Joined: Sun Apr 28, 2013 10:38 pm

Previous

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 10 guests