Solved How do I configure VS code

Hi there,

Anyone care to share the experience on configuring VS code for C/C++? I've been trying to make it work but no success. All necessary tools were installed via packages. I didn't install gcc or g++ though as I suppose llvm/clang would suffice.
Debugging a simple "hello world" program gives me error message:
Couldn't find a debug adapter descriptor for debug type 'cppdbg' (extension might have failed to activate)

As instructed by some posts on web, MS C/C++ extension has been removed and installed several times still no luck.

Many thanks.
 
I doubt if VSCode is the best "IDE" for such tools/languages, maybe on some Microsoft platforms but not on FreeBSD.
I also had a problem with setting up VSCode with Haskell but in my case it was rather some mysterious issue with language server (lsp). I eventually gave up and switched to Emacs.
Although I'm not actively using C/C++ for ~7 years I remember that in my case the best cross-platform IDE was Netbeans. It didn't require any additional files to manage project, just plain Makefiles, much better than Eclipse with CDT at that time...
 
Thanks for the info. I have no experience on Netbeans. If VSCode doesn't work out for me, maybe I'll try vim, which I sense won't be easy. I thought configuring VSCode was relatively easy.

I just tried more configuration options and it turns out that code-lldb which is the most popular lldb extension on VSCode doesn't support FreeBSD.
 
If VSCode doesn't work out for me, maybe I'll try vim
IMHO, just go for it (that's what I use for any personal C or C++ project). Or, if you prefer, emacs (I don't get it, but some prefer that...).

If you want some of the "convenience" stuff big fat IDEs offer, there are interesting extensions for both editors ;)
 
Vim is not a comparison to make. Vscode helped find the 10,000 functions needed to program Windows. I don't know why it's used on other operating systems but I'm used to what I do and it works well as FreeBSD is my ide
 
If you want some of the "convenience" stuff big fat IDEs offer,
Could we discuss this some. I use ee to write a small amount of code I have written.
What is the real difference between using an IDE or a text editor.
Obviously ee doesn't contain any programming plugins. So it's raw text coding.

What are some of the IDE-like features that you find productive?
I know from my playing that you get different colored text with IDE.
Auto formatting. Pre-baked functions.

But by using a text editor you are forced to learn the command line options for compiling.
That is a good thing.

So from a fundamentals standpoint you should first learn how to write and compile hello_world from a text editor.
Agreed?
 
What are some of the IDE-like features that you find productive?
I know from my playing that you get different colored text with IDE.
I have become weak in my old age. It's simply easier for me to read colorized code. I also like conveniences like ctrl - / comments out a line.

Beyond that, it's nice to have API documentation at your fingertips. I could never remember all the arguments to all APIs and their intricacies. Having them a keystroke away is a lot faster than looking them up in the Web or in a man page. I also like a tree panel that expands out into all the functions in a C file or all the methods in a Java class.

I'm not super in love with Vscode. I'm impressed it works on Freebsd, but it is a pig, and building it from source is a giant pain.

Another thing I found is that if you use its "Open folder" function, it will scan every file in that folder with Ripgrep. This is a ton of fun for large directory structures with lots of text files. I made the mistake of opening a folder that had several jails all with ports directories in it. It took me a while to figure out it was Vscode that was causing X to become unresponsive because it wouldn't happen right away. This is one of the downsides of having an NVMe drive. There's no sound to warn you when some tool is doing something criminally stupid.

So from a fundamentals standpoint you should first learn how to write and compile hello_world from a text editor.
Agreed?
Agreed!
 
Last edited:
I also like a tree panel that expands out into all the functions in C file
That is a big advantage of an IDE versus text editor.
The tree view.
View all files in a project in tree view and expand functions as you mention.

So good for visualization of work.
 
Lets not forget that magical compile button.
Showing you visually where your code fails.
Text editor can be hard in this manor.
Compilers do give reasonable error messages and suggestions.
 
What are some of the IDE-like features that you find productive?
Features I just don't want to code without:
  • syntax highlighting (colored)
  • auto-indent (if possible, the "smart" kind that knows the language grammar)
  • a powerful search-replace function, ideally using regular expressions (ok, that's not only for programming)
  • quickly jump to matching parantheses, brackets, etc
Features I consider useful, but still use rarely:
  • code folding
  • auto-completion with suggestions
 
What are some of the IDE-like features that you find productive?
I'm not advocating for big IDEs, quite opposite, I switched recently from IntelliJ Idea to VSCode and then to Emacs but... there are some things where IDEs rock:
- Ease of refactoring, in fully fledged IDE I have some magic shortcuts that can rename function/method across all project modules, change type and order of it's parameters and so on.
- Auto imports, suppose I want to use some function/method/object from some module/library and I don't remember where it comes from - big fat IDEs cache all that information for me and with one or two clicks I can import what I want, add it to dependencies, without googling it.
- Support for languages, libraries, frameworks, build systems out of the box or with dedicated plugins. IDEs come with "batteries included", raw editors need often need a lot of manual configuration.

I agree, maybe it's not good for learning.
I agree it make us somehow weak in terms of knowledge and awareness.

But all this fancy features can make us also very productive.
 
How does vim + plugins handle inline compiling code and does it jump to code and highlight errors?
It seems that is an advanced feature that full fledged IDE's use.
 
How does vim + plugins handle inline compiling code and does it jump to code and highlight errors?
It seems that is an advanced feature that full fledged IDE's use.
There's at least one plugin doing just that (probably more). I can't remember the name, tried it MANY years ago and found it too "sluggish" on my machine. I can live very well without that, but I really hate coding without the basic features I mentioned above ;)
 
So do you drop back to shell for compiling or use <F@> virtual terminal?
Shell out under vim?
I got used to tmux. Window 1 is the compiler/shell window ;)

On the general topic: I didn't find any "IDE" (or "similar" like VS code) where I didn't found the editor quite lacking. If you're used to some powerful features in vim (probably same for emacs), you'll miss them, and no fancy IDE feature can make up for it. But that's just MY personal taste of course :)

(edit: raise your hands if you ever hit <ESC> trying to type some command in visual studio, eclipse, what-not-fancy-crap ... 😈)
 
Just for clarity, When I said compile code 'inline' I mean checking with a shortcut key, not constant checking.
Ok, the plugin I tried back then somehow interfaced with llvm to implement "compile-as-you-type", which is quite heavy-weight. Well, maybe not on today's hardware.
 
Looks "native debug" works for me as alternative to codelldb, at least now i can compile "hello world".
In the meantime, I installed a bunch of plugins to vim, now it has cindent, syntax highlight, etc.
 
IMHO, just go for it (that's what I use for any personal C or C++ project). Or, if you prefer, emacs (I don't get it, but some prefer that...).

If you want some of the "convenience" stuff big fat IDEs offer, there are interesting extensions for both editors ;)

I also prefer to use VS code, in my opinion I think VS code is probably the best modern text editor which can be made into a modern general c/c++ IDE. I also like how VS code is extremely customizable so that the programmer can make the IDE to their liking.

Can you share the steps required to get a working c/c++ IDE for VS code on FreeBSD 13.1?

Thanks.
 
Back
Top