Nico
Nico

Reputation: 27

VS Code auto-completion with std and other libraries

I am using VS Code, I have installed C/C++ extension of Microsoft for auto completion. It works for everything in my own project, but my real interest is having auto-completion for things that are not in my project, for example the std lib. If I declare, for example

std::fstream mystream;

I would like to then see the functions of the fstream when I put my dot next to mystream.

I found out a bit on how to do that, maybe it would be by going into the c_cpp_propertiese.json file but from there, I do not know what to do because I do not know where the std is located or how I would need to write what is necessary.

So the real question is, how do I add inside the configuration files of the extension C/C++ some includes in order for my VS Code to autocomplete any external libraries?

Thank you, may this help for other people trying to use VS Code :)

Upvotes: 1

Views: 2352

Answers (2)

MSalters
MSalters

Reputation: 179779

This isn't something you're going to fix yourself.

The problem that you're facing is that you need compiler assistance. In the "real" Visual Studio, that's provided by Intellisense. This includes a C++ compiler (surprisingly enough, not Microsoft's own but EDG's). Since it's a compiler, it's smart enough to figure out what std::fstream really is: std::basic_fstream<char>, a template. Instantiating that gives Intellisense a list of members.

But without the Intellisense compiler, VS Code cannot figure out the members of that template.

Upvotes: 4

Kevin SUN
Kevin SUN

Reputation: 158

It works in my VS2008, while you must include the corresponding header file firstly.

Upvotes: -3

Related Questions