Partager via


Intellisense in VC++

Reader zakimirza asks:

Just needed to ask a simple thing. Why is there such a huge Intellisense support for C# in VS 2005 and not for C++ in the same IDE. intellisense is just a helper tool that i guess is a part of VS 2005 and should be applicable to every programming/scripting editor in the studio as is. no? or am i missing something here that intellisense in C++ mode is a different story in intellisense in C# mode or VB mode. (coudnt find a "ask me" or "contact me" thingie on the blog so posting here)

Good question.  Let me preface by saying that you're totally right: Intellisense is a very valuable tool for developers, and it should be every bit as good for the C++ language as it is for the C# language.  The problem is, of course, that Intellisense support for C++ really isn't as good as it is for C# or VB.NET.  This begs the questions: 1. why is this the case, and 2. if we know it's a problem, what are we doing about it?

Why is this the case?
Part of the answer here is that C++ is a much more complex language, so it's a tougher problem in general.  C++'s preprocessor, lack of a language-based notion of modules, and general funky lookup rules all play various supporting roles in this complexity.  However, to blame it all on language complexity wouldn't be fair or accurate because, despite the complexity of the language, we have some very good engineers on the team that understand this problem and are perfectly capable of solving it.

The more onerous problem is that the infrastructure we have in place today is far from optimal for solving this problem.  Our C++ compiler front-end is actually really good at making sense of even the hairiest C++ code and even compiling it to a binary if the code is valid.  However, our C++ compiler front-end is a very old piece of code (portions of it are well over 20 years old!).  It was designed in an era when compilers needed to use as little memory as possible and any thought of a compiler interacting with an editor to provide something like Intellisense wasn't even yet the stuff of science fiction.  Those original design constraints have created a situation today where providing interactive, incremental information to the IDE is a difficult engineering challenge. 

Fine, then what are you doing about it?
Today the VC++ team is investing a significant amount of resources in a building a new compiler front-end infrastructure that is designed from the ground up to work hand-in-hand with the IDE and tools.  This is an investment for which it will actually take several years to our realize full return, so you won't begin to see the fruits of this effort until after the Orcas release of Visual Studio.  Meanwhile, we'll continue devoting some resources to tweaking the current infrastructure to get the most out of it.

Comments

  • Anonymous
    February 07, 2007
    Visual StudioのC++エディタのインテリセンスが貧弱なのはなぜですか?

  • Anonymous
    February 07, 2007
    Perhaps the most powerful feature you could add for intellisense in Orcas is a simple way to turn it off. This way we can use other(better) tools.

  • Anonymous
    February 07, 2007
    The comment has been removed

  • Anonymous
    February 08, 2007
    zakimirza, We're definitely tracking C++0x, and inclusion of the new standard is definitely in our plans when the time comes.  Many feel that 2009 is an optimistic goal for ratifications of the new standard, but only time will tell.  :) To do intellisense requires most of the same facilities as a "batch" compiler front-end.  While intellisense vs. compilation occur in a different context for the end-user, the job they do in terms of parsing C++ code an rendering it to some kind of intermediate format is largely the same.  Therefore, from an engineering standpoint, it makes sense to consolidate this functionality into a common code base so that new features and functionality can be added in one place and bugs can be fixed in one place.  We do this to some extent today, but the compiler code is so heavily ifdef'd for intellisense that we lose much of the advantage of a common code base.

  • Anonymous
    February 08, 2007
    My intuitive feeling is that one of the biggest problems C++ poses to Intellisense is which macros should be expanded before presenting the results to the user and which macros should be presented as-is.  C# and VB avoid this problem. #ifdef's in SDKs compound the problem.  I wouldn't want to turn it off[], the problem is that it turns itself off.  Now I'm trying to remember if Intellisense in eVC++4 was really as usable as my memory asserts it was, or if it was just a figment of my imagination. [ Though when someone else wants to turn it off, I favour permitting them to do so.]

  • Anonymous
    February 11, 2007
    Hmm that solves the mystry for me :) but if thats such a problem of #ifdef's , then it might never get solved since no ones going to touch that legacy code anyway, so gotta find another solution [which would have been there in place if one had existed :p]. I had switched to C# pretty much for my freelance projects but i need to do native C and/or C++ programming every now and then and its like your left with nothing. C/C++ are here to stay and have a more solid and promissing future than C# (since its only a matter of time that microsoft embraces open source as well [atleast to some level], but thats just a personal opinion).Having a lot of great applications written still in native C/C++ (e.g. apache server, apache portable runtime etc), Steve's team really needs to push it cross the limit before we get more state-of-the-art IDE for one of the most powerful language in the world. I wouldnt reallly call C# syntatic sugar, but if microsoft can promote more  c/C++ culture, better, higher performance applications can come forward on an even greater pace.

  • Anonymous
    March 03, 2007
    Thanks for this wonderful blog. This is a very useful piece of information to learn that Intellisense does not really work in C++: actually it would be so useful that Microsoft publishes official information about what works and what does not so programmers stop googling around with always the same questions. This information would turn MSDN library into something really useful. For instance link below about VS2005 could report known issues about Intellisense with C++/CLI: http://msdn2.microsoft.com/en-us/library/ms364071(vs.80).aspx

  • Anonymous
    March 05, 2007
    IntelliSense is valuable (to me), but the implementation is anything but "Intelligent". I have a large C++ project, and Intellisense has been running for 4 days straight (still not finished).  35 hours of CPU time, 6,221 handles, pegging the cpu at 96-99% so that no other work can be done. Don't you guys run PerfMon on your code?  Intellisense implementation is over-the-top, ridiculously slow, and perfmon gives you quick insight into where that time is going. Why, for example, aren't you using mapped files for the "solution".ncb file?  b'zillions of writes for each file.