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

Sublime​Linter-gcc

by SublimeLinter ST3

This linter plugin for SublimeLinter provides an interface to gcc or other gcc-like (cross-)compiler.

Details

  • 3.0.0
    2.0.1
  • github.​com
  • github.​com
  • 9 months ago
  • 1 hour ago
  • 8 years ago

Installs

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

Readme

Source
raw.​githubusercontent.​com

SublimeLinter-gcc

Package Control GitHub tag (latest SemVer) Project license GitHub stars Donate to this project using Paypal

This linter plugin for SublimeLinter provides an interface to gcc or other gcc-like (cross-)compiler. It will be used with files that have the C/C++ syntax. If you are using clang, you may want to check SublimeLinter-clang.

Installation

SublimeLinter must be installed in order to use this plugin. If SublimeLinter is not installed, please follow the instructions here.

Linter installation

Before using this plugin, you must ensure that gcc or other gcc-like compiler is installed on your system.

You may install gcc with the following method:

Once gcc is installed, you must ensure it is in your system PATH so that SublimeLinter can find it. This may not be as straightforward as you think, so please read Debugging PATH problems in the documentation.

Plugin installation

Please use Package Control to install the linter plugin. This will ensure that the plugin will be updated when new versions are available. If you want to install from source so you can modify the source code, you probably know what you are doing so we won't cover that here.

To install via Package Control, do the following:

  1. Within Sublime Text, bring up the Command Palette by Ctrl + Shift + P and type install. Among the commands you should see Package Control: Install Package. If that command is not highlighted, use the keyboard or mouse to select it. There will be a pause of a few seconds while Package Control fetches the list of available plugins.

  2. When the plugin list appears, type gcc. Among the entries you should see SublimeLinter-gcc. If that entry is not highlighted, use the keyboard or mouse to select it.

Settings

Here are some most frequently used custom settings.

Setting Description
executable The compiler's binary path. This is ["gcc"] or ["g++"] by default. If you are not using them, you have to set this to your compiler binary such as ["arm-none-eabi-gcc"].
I A list of directories to be added to the header's searching paths. I.e., paths for -I flags.
args A list of extra flags to be passed to the compiler. These should be used carefully as they may cause linting to fail.

Here is an example settings:

{
    "linters":
    {
        "gcc": {
            "disable": false,
            "executable": ["gcc"],
            "args": ["-fsyntax-only", "-std=c90"],
            "I": [
                "${file_path}/include",
                "${folder}/include",
                "/usr/local/include",
            ],
            "excludes": [],
        },
        "g++": {
            "disable": false,
            "executable": ["g++"],
            "args": ["-fsyntax-only", "-std=c++20"],
            "I": [
                "${file_path}/include",
                "${folder}/include",
                "/usr/local/include",
            ],
            "excludes": [],
        },
    },
}

Here are some useful docs for SublimeLinter settings.

Notes

  • Here is the official list of warning options in gcc 13.2.0. I prefer turn on all warnings via -Wall (this is default for this plugin) and then suppress unwanted warnings via -Wno- prefix.

  • Use the -fsyntax-only flag in args gives a much faster syntax-only checking but some warnings which are emitted in the code optimization phase would not be caught.

Demo

linting_example

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 settings I.
  • Sometimes gcc fails to locate the C/C++ standard library headers.

Assuming the compilation works when executed via command line, try to compile with g++ -v. This will display all of the hidden flags that gcc uses. As a last resort, they can all be added in settings args.

Contributing

If you would like to contribute enhancements or fixes, please do the following:

  1. Fork the plugin repository.
  2. Hack on a separate topic branch created from the latest master.
  3. Commit and push the topic branch.
  4. Make sure your modification could pass unittests.
  5. Make a pull request.
  6. Be patient.

Please note that modifications should follow these coding guidelines:

  • Indent is 4 spaces.
  • Code should pass flake8 and pep257 linters.
  • Probably format codes with black code formatter.
  • Vertical whitespace helps readability, don’t be afraid to use it.
  • Please use descriptive variable names, no abbreviations unless they are very well known.

Thank you for helping out!