ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Sublime​Linter-clang

by SublimeLinter ST3 Trending

SublimeLinter plugin for C/C++, using clang

Details

Installs

  • Total 50K
  • Win 20K
  • Mac 12K
  • Linux 17K
Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2 Mar 1 Feb 28 Feb 27 Feb 26
Windows 4 5 12 7 3 4 4 5 5 7 4 6 4 6 6 4 4 6 2 9 4 3 4 4 5 5 4 2 5 2 1 7 5 4 5 3 3 3 7 7 6 3 8 3 2 4
Mac 2 2 3 6 1 5 2 4 0 1 0 1 2 3 2 3 1 6 4 3 2 1 2 2 1 4 5 4 2 2 0 1 4 3 6 0 3 3 0 2 5 1 2 4 1 3
Linux 3 1 5 2 3 5 4 3 3 1 11 2 3 8 4 8 3 2 6 4 7 2 2 5 4 4 4 8 4 7 2 5 3 11 2 1 3 2 5 12 9 3 5 2 5 3

Readme

Source
raw.​githubusercontent.​com

SublimeLinter-clang

This linter plugin for SublimeLinter provides an interface to clang. It will be used with files that have the C/C Improved/C++ syntax.

Installation

SublimeLinter must be installed in order to use this plugin.

Please use Package Control to install the linter plugin.

Before using this plugin, ensure that clang is installed on your system. - Mac OS X: clang should be already bundled. - Linux: clang can be easily installed using most package managers. - Windows: the situation is a little trickier, especially with C++. One way to go is to install mingw with clang. Both gcc and clang packages should be installed into the same directory.

Once clang is installed, ensure it is in your system PATH so that SublimeLinter can find it. The docs cover troubleshooting PATH configuration

Settings

We have two settings sections. 'clang' for c files, and 'clang++' to configure the linter for c++ files. E.g.

{
    "linters":
    {
        "clang": {
            "args": "-fvery-important",
            "I": [
                "${folder}/3rdparty/bar/include",
                "${folder}/3rdparty/baz"
            ]
        },
        "clang++": {
            "args": "-falso-important"
        }
    }
},

Note: 'args' has the default value '-Wall -fsyntax-only -fno-caret-diagnostics', so make sure to include them when overriding 'args'.

All common settings information can be found here:

Additional settings for SublimeLinter-clang:

Setting Description
I A list of directories to be added to the header search paths.
isystem A list of directories to be added to the system header search paths.
x Automatically set depending on the file type.

SublimeLinter allows expansion variables. For example, '${folder}' can be used to specify a path relative to the project folder.

Troubleshooting

C/C++ linting is not always straightforward. A few things to try when there's (almost) no linting information available: - Try to compile from the command line, and verify it works. - The linter might be missing some header files. They can be added with “include_dirs”. - Sometimes clang fails to locate the C++ standard library headers. Assuming the compilation works when executed via command line, try to compile with clang++ -v. This will display all of the hidden flags clang uses. As a last resort, they can all be added as “args”.