lvzixun / Clang-Complete

a auto complete plugin for sublimetext3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cc_include_options

Falven opened this issue · comments

Hi,

`error: invalid argument '-std=gnu++1y' not allowed with 'C/ObjC'`
`error: invalid argument '-std=c++14' not allowed with 'C/ObjC'`
`error: invalid argument '-std=c++11' not allowed with 'C/ObjC'`

cc.sublime-settings

"additional_language_options":
{
    "c++" : ["-std=gnu++1y"],
    "c": ["-std=c89"],
    "objc": [],
    "objc++": []
}

-std=c++1y instead of -std=gun++1y.
require restart sublime-text 3.

error: invalid argument '-std=c++1y' not allowed with 'C/ObjC'
:/

If I leave the flag off I get a large array of messages:

fatal error: too many errors emitted, stopping now
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/bits/c++config.h:153:1: error: unknown type name 'namespace'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/bits/c++config.h:153:1: error: expected ';' after top level declarator
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/cstddef:53:1: error: unknown type name 'namespace'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/cstddef:53:1: error: expected ';' after top level declarator
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/cstring:78:1: error: unknown type name 'namespace'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/cstring:78:1: error: expected ';' after top level declarator
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/wait.h:251:22: error: unexpected type name 'id_t': expected identifier
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/wait.h:251:28: error: unexpected type name 'siginfo_t': expected identifier
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/wait.h:251:38: error: expected ')'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/wait.h:251:12: error: a parameter list without types is only allowed in a function definition
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/cstdlib:104:1: error: unknown type name 'namespace'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/cstdlib:104:1: error: expected ';' after top level declarator
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/clocale:57:1: error: unknown type name 'namespace'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/clocale:57:1: error: expected ';' after top level declarator
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/cstdio:98:1: error: unknown type name 'namespace'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/cstdio:98:1: error: expected ';' after top level declarator
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/cstdarg:58:1: error: unknown type name 'namespace'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/cstdarg:58:1: error: expected ';' after top level declarator
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/bits/gthr.h:122:13: error: #pragma visibility pop with no matching #pragma visibility push
fatal error: too many errors emitted, stopping now

psdl.sublime-project

{
    "folders":
    [
        {
            "path": "."
        }
    ],

    "settings":
    {
        // if "cc_include_options" exists in your project settings, it'll override rather than add to the "include_options" defined in cc.sublime-settings.
        "cc_include_options":
        [
            "-I/Users/francisco/Cpp/psdl/include",
            "-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/6.0/include",
            "-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/",
            "-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1",
            "-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/",
            "-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
            // "-isystem", "/usr/include",
            // "-isystem", "/usr/include/c++/*",
            "-isystem", "/usr/local/opt/llvm/include",
            "-Wall"
        ]
    },

    "build_systems":
    [
        {
            "name": "make",
            "shell_cmd": "make",
            "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
            "working_dir": "${project_path}/build",
            "selector": "source.makefile",
            "variants":
            [

                {
                    "name": "Clean",
                    "cmd": ["make", "clean"]
                },

                {
                    "name": "Doc",
                    "cmd": ["make", "doc"]
                },

                {
                    "name": "Test",
                    "cmd": ["make", "test"]
                }
            ]
        }
    ]
}

cc.sublime-settings

{
    // Additional language specific options for clang.
    "additional_language_options":
    {
        // For example, you can use "c++": ["-std=c++11"] to enable C++11 features.
        "c++": ["-std=c++1y"],
        "c": ["-std=c89"],
        "objc": [],
        "objc++": []
    },

    // open or close inhibit the sublime text 3 built in word completions
    "inhibit": true,

    // add include options to clang
    // this can also be specified as project specific options.
    // add somthing like the following to the `sttings` section in your `<name>.sublime-project` file:
    // 
    // 
    //     
    // "settings":
    // {
    //     "cc_include_options":
    //     [
    //         "-I/headfile_path1",
    //         "-I/headfile_path2",
    //         "-I/headfile_path3",
    //         ...
    //     ]
    //     ...
    // }
    // if "cc_include_options" exists in your project settings, it'll override rather than add
    // to the "include_options" defined in cc.sublime-settings.
   "include_options":
   [
        "-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/6.0/include",
        "-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/",
        "-isystem", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1",
        "-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/",
        "-isystem", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
        // "-isystem", "/usr/include",
        // "-isystem", "/usr/include/c++/*",
        "-isystem", "/usr/local/opt/llvm/include",
        "-Wall"
    ],
}

You can find the source I am using here. It all compiles fine using cmake and make.

It is interesting to note that the following:

"cc_include_options":
[
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
"-Wall",
"-I/Users/francisco/Cpp/psdl/include"
]

yields:

warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1: 'linker' input unused
/Users/francisco/Cpp/psdl/include/pslogin.h:4:10: fatal error: 'vector' file not found

Which tells me that it is not including the std headers path defined above.

Tell me if I am wrong but, are you calling cc for all of c++, c, obi-c, and obj-c++ files? Because that would be the problem, clang++ needs to be called for c++...

Looking at your tests, this seems to be the problem. Seems like you never tested c++ support as is advertised!

I lost -x<language> option when create CXTranslationUnit object. so clang default C/ObjC language.
commit a50a478 for bugfix.

view #2 issue, set STL headfile.

/Users/francisco/Cpp/psdl/include/psclient.h:36:40: warning: deleted function definitions are a C++11 extension
/Users/francisco/Cpp/psdl/include/psclient.h:39:23: warning: rvalue references are a C++11 extension
/Users/francisco/Cpp/psdl/include/psclient.h:39:35: warning: defaulted function definitions are a C++11 extension
/Users/francisco/Cpp/psdl/include/psclient.h:42:52: warning: deleted function definitions are a C++11 extension
/Users/francisco/Cpp/psdl/include/psclient.h:45:35: warning: rvalue references are a C++11 extension
/Users/francisco/Cpp/psdl/include/psclient.h:45:47: warning: defaulted function definitions are a C++11 extension

"additional_language_options":
{
    // For example, you can use "c++": ["-std=c++11"] to enable C++11 features.
    "c++" : ["-std=c++11"],
    "c": ["-std=c89"],
    "objc": [],
    "objc++": []
},

are you sure modify <sublime text 3 directory>/Package/Clang-Complete/cc.sublime-settings file?

I clone repo https://github.com/Falven/psdl.git. and not found diagnostic error.
I think that if you load SublimeClangFormat plugin? from screenshot( #14 ), st_cc.py, clang.py, enum.py, clang_error.py, cc.py should be included in the Clang-Complete plugin.