Giter Club home page Giter Club logo

linter-gcc's Introduction

linter-gcc

Join the chat at https://gitter.im/linter-gcc/Lobby Travis apm Paypal

Linter plugin for Linter, provides an interface to gcc/g++.

Used with files with grammar "C", "C++" and "C++14".

Now with linting on-the-fly! This is a new feature so please open an issue if you encounter any problems.

Important info for Mac OSX users!

If you have XCode installed on OSX, the gcc/g++ commands will both link to clang. This can cause issues with the -fmax-errors option used by linter-gcc, which isn't recognised by clang. To properly install GCC, you need to install it with Homebrew (instructions here).

Linter in action!

linter-gcc screenshot

Using CMake compile settings

linter-gcc can take compile settings from CMake. Using my gtf2tab project as an example, this is what you need to do:

git clone https://github.com/hebaishi/gtf2tab
cd gtf2tab
mkdir build
cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..

Running cmake with the -DCMAKE_EXPORT_COMPILE_COMMANDS flag generates a compile_commands.json file which linter-gcc can get the compile settings from. Then you simply open the project in Atom, and enter ./build/compile_commands.json in the Compile Commands File setting of linter-gcc. Note that if you supply a valid compile_commands.json file, your include paths and compile flags configuration settings (described below) are ignored.

File/Project-Specific settings

Assuming you have the a file called sample.cpp open, linter-gcc performs the following actions:

  1. Looks for file called sample.cpp.gcc-flags.json in the same directory as your source file (file-specific settings)
  2. Looks for a file called .gcc-flags.json in every subdirectory from the current up to your project root (subdirectory/project-specific settings)
  3. If no .gcc-flags.json is found, the settings in your configuration page are used.

The package takes its settings from the first configuration file that is found.

You can specify your settings in .gcc-flags.json, at any level (file/subdirectory/project) using the following syntax:

{
  "execPath": "/usr/bin/g++",
  "gccDefaultCFlags": "-Wall",
  "gccDefaultCppFlags": "-Wall -std=c++11",
  "gccErrorLimit": 15,
  "gccIncludePaths": ".,./include,./path",
  "gccSuppressWarnings": true
}

Note that the include paths need to be separated by commas. If this file is present, it will replace the settings you specified in the settings window. Relative paths (starting with . or ..) are expanded with respect to the root folder. Both execPath and gccIncludePaths are expanded.

In order to avoid unwanted behavior associated with having multiple projects open, only the paths within the first project are used, and the package limits its search to 30 levels when looking for a configuration file. You can work with multiple projects, as long as each is open in a separate window. Additionally, within each project, you may have as many file/directory-specific configuration files as you wish.

Usage notes:

  • Add -fsyntax-only to your C/C++ compilation flags to prevent the generation of .gch files when linting headers
  • Add -c to your flags to avoid linking errors.

Plugin installation

Press ctrl and ',' or cmd and ',' , click on 'Packages', search 'linter gcc', or:

$ apm install linter-gcc

Reporting Issues

Please read the Wiki before reporting any issues.

linter-gcc's People

Contributors

hebaishi avatar marcangels avatar nyorain avatar guysherman avatar keplersj avatar lukeshingles avatar mkstayalive avatar engelmarkus avatar matlegat avatar gitter-badger avatar

Watchers

James Cloos avatar Will Da Silva avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.