Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Real-time linting of C code

Tags:

c

lint

I am looking for something similar to the JavaScript linting tools JSHint or JSLint for C. My text editor (Sublime Text 2) has a JSHint pluggin that gives me real time feedback to my JavaScript code.

What is the best way to get feedback about the quality of my C code? Are there any tools that could give me real time linting?

like image 925
Randomblue Avatar asked Jul 06 '12 16:07

Randomblue


2 Answers

I've concocted a way to drop some user-made linters written for SublimeText 2 into the mix to get the linting working with SublimeLinter and ANSI C. Also note, this is a slightly 'hacky' way of getting it to work.

  • You must have clang installed (for OS X you can use Apple's command line tools to install clang/the LLVM compiler, which requires only a developer account, which is free), you also must have SublimeLinter installed in Sublime Text 2

  • Navigate to this user's fork of SublimeLinter and proceed to download the 'c.py' module from the modules folder

  • Copy this module into SublimeLinter's working modules directory located under **your SublimeText 2 data directory**\Packages\SublimeLinter\sublimelinter\modules\ (see this for further information on the data directory)

  • Restart Sublime Text 2



†Be sure that the current language in the lower right-hand corner of the window is set to 'C', not 'C++', 'Python', ect.
like image 110
Eli Avatar answered Nov 08 '22 02:11

Eli


Take a look at the Clang Static Analyzer and Gimpel's PC-lint and FlexeLint

like image 3
Doug Currie Avatar answered Nov 08 '22 03:11

Doug Currie