4

I am using emacs as my only programming editor. But recently I have been struggling for hours with problems that, at the end, turned out to be simple mistakes from my side. For instance, writing if(n < n) instead of if(n < N), or declaring the function as bool instead of double:

bool foo() {
   return 0.5;
}

Neither gcc -Wall nor emacs was able to detect those problems.

Is there any IDE around that can do this? It should

  • work on linux
  • be free
  • be able to show various issues in code, not just syntax errors

Additionally I would love

  • usable on small screens (possible to focus on a single window and hide all titlebars/menus/icons...)
  • recognize emacs keybindings
3

Since you're already using emacs, I'm wondering if fitting one of the many open source linters onto it might be preferred over an IDE? That way's probably more flexible than an IDE, and you get to stay in your One True Editor.

For C++, there are these linters to choose from:

If you're not yet attached to your editor, Vim has Syntastic to integrate these so that your file is automatically checked as you type or when you save.

Several of these know how to generate emacs-ready output.

Unfortunately, on my system, neither gcc, clang_check, nor cpplint complained about your two testcases. Even with g++ -ansi -pedantic -Wall -Wextra -Weffc++.

Of the list above, cppcheck might be the one most likely to catch your testcases, being a static analysis tool ("not a compiler" as they say in the docs).

In fact, it did catch your n<n case:

$ cppcheck --enable=all test.cc
[test.cc:17] -> [test.cc:17]: (style) Same expression on both sides of '<'.

Maybe a C++ programmer can chime in here why returning something other than the declared bool in your testcase is not something tools crow loudly about.

Each linter/compiler listed above has a myriad of options - maybe their sensitivity can be cranked up to catch both of your cases.

I realize you asked for an IDE, but a good editor with plugins and a good setup is sometimes indistinguishable from an "IDE".

2

I'd suggest you to at least try sth like a static code analysis software like c++ linter.

Although, it partly solves your problem, i found such programs demanding very high standards and therefore very stressful to use in the beginning. Additionally, according to that post, it has trouble to detect more complicated setups.

  • Thank you toogley. I am also thinking that what I need does not have to be ide, but may well be a stand-alone application I can feed my code to (even web-based) when I run into different issues. – Ott Toomet Dec 23 '15 at 21:52
  • @OttToomet Some of them can be also integrated with IDE'S. E.g. for eclipse – toogley Dec 24 '15 at 15:47
1

Vim/Neovim?

enter image description here


But before anything, static analyzers have their place and aren't suited well while editing your file. Run them when you've made your edits and before committing your code, therefore removing any common nifty errors that might've crept in your code. Take a look at oclint, cppcheck, clangcheck, clang-tidy, clang-static-analyzer.


I can tell plenty of plugins to enhance your workflow but one that is essential is YouCompleteMe. See those red cross marks on left-most buffer? Those will update in the background as you type and tell you where you might've made a mistake.


YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for Vim. It has several completion engines:

  • an identifier-based engine that works with every programming language,
  • a Clang-based engine that provides native semantic code completion for C/C++/Objective-C/Objective-C++ (from now on referred to as "the C-family languages"),

  • a Jedi-based completion engine for Python,

  • an OmniSharp-based completion engine for C#,

  • a Gocode-based completion engine for Go,

  • a TSServer-based completion engine for TypeScript,

  • a Tern-based completion engine for JavaScript.

  • and an omnifunc-based completer that uses data from Vim's omnicomplete system to provide semantic completions for many other languages (Ruby, PHP etc.).

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.