Skip to main content
GameDev.net gamedev.net
🔒 Locked

Intellisense and C++

Started by Dalek_Supreme Jun 24, 2010 at 10:50 AM 39 replies 11.6k views
Original Post
Dalek_Supreme
Dalek_Supreme
I just started coding in C++ recently (I know a bit of Java and C#) and I know that in C#, Intellisense displays descriptions of functions (for example, if I start typing
Console.Write
I get "Writes the specified string value to the standard output stream".

However, if I write
std::cout
, I get "std::ostream std::cout" (which to me, is like alien writing).

So, my question is, is there any way to make Intellisense display something like C#? (I am using Visual Studio 2010 Professional)
Burnhard
Burnhard
Well, what's it's showing you there is correct. std::ostream is returned from the function! If you want it to show C# style function definitions, you need to use C#.
jpetrie
jpetrie
It's displaying the correct thing as far as it can tell. std::cout is an instance of the std::ostream type. If you were to, for example, type "std::cout." (no quotes) you'd get member functions listed. Console is a class name in C#, so typing "Console." lists the static methods.

There's no way to customize the Intellisense behavior to that extent. Some third-party plugins, like VAX, can augment the suggestions based on what you've previously typed, and sometimes that can show you "operator<<" but not always.
Burnhard
Burnhard
Also remember that C++ intellisense is hard to do for VS (in fact it was often totally broken in earlier versions). It has to do a partial compile in the background in order to generate its symbol database. It's much better in 2010, but still not perfect.
taz0010
taz0010
Intellisense is broken in some of my classes, and I've got no idea what causes it. And the right click - "go to definition" function is broken in those classes too. Hope they fix it in 2010 cause they didn't in 2008.
XTAL256
XTAL256
He mentioned that it displays a description:
"Writes the specified string value to the standard output stream"

So i assume he wants Intellisense to display a similar description for std::cout.
In that case, the description is taken from a comment above the function declaration, AFAIK. So if you declare/define a function like this:
/* This is a description of what the function does */void someFunction(int var);

Then VS will show a popup with this text:
void someFunction(int var)This is a description of what the function does

If the function does not have such a comment, then Intellisense cannot display it.
Also, std::cout is not a function, it is a global variable.
[Window Detective] - Windows UI spy utility for programmers
Erevis
Erevis
The NetBeans IDE has a very good auto-completion functionality. For libraries that come with documentation (e.g guichan) it shows info about object and object methods like VC# does. You can also create tags above your functions to display your own info as well.

The downside is that you can't use microsoft's compiler for C++, you have to download either mingw32 or cygwin.
my game development site:http://sites.google.com/site/billgamedevelopment/
phresnel
phresnel
Quote:
Original post by Burnhard
Also remember that C++ intellisense is hard to do for VS (in fact it was often totally broken in earlier versions). It has to do a partial compile in the background in order to generate its symbol database.


And how do you think the intellisense database is generated for C# code without compiling?
ChaosEngine
ChaosEngine
Quote:
Original post by phresnel
Quote:
Original post by Burnhard
Also remember that C++ intellisense is hard to do for VS (in fact it was often totally broken in earlier versions). It has to do a partial compile in the background in order to generate its symbol database.


And how do you think the intellisense database is generated for C# code without compiling?


To be fair, C# is a lot easier to parse than C++
if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight
phresnel
phresnel
Quote:
Original post by ChaosEngine
Quote:
Original post by phresnel
Quote:
Original post by Burnhard
Also remember that C++ intellisense is hard to do for VS (in fact it was often totally broken in earlier versions). It has to do a partial compile in the background in order to generate its symbol database.


And how do you think the intellisense database is generated for C# code without compiling?


To be fair, C# is a lot easier to parse than C++


Indeed, but still, please excuse me, Burnhard was wrong, as every language must be [partially] compiled to reap information from it.

Anyways, for the curious, the reason why C# is faster to parse than C++ is that C++ contains many highly ambiguous parts, that is, pieces of source code can be arithmetics, declarations or something else, depending on sometimes large context.
Nitage
Nitage
Quote:
Anyways, for the curious, the reason why C# is faster to parse than C++ is that C++ contains many highly ambiguous parts, that is, pieces of source code can be arithmetics, declarations or something else, depending on sometimes large context.


It's been my experience that preprocessing (and it's implications) is the really taxing part of a C++ compilation.

A C# compiler has to parse each file in the project once and extract the metadata from any referenced assemblies.

A C++ compiler has to preprocess each file in the solution before parsing it; library interfaces are distributed as headers, so the compiler not only has to trawl many more files, when it finaly comes to do the parsing, each file has (often) tens of thousands of extra lines of code #included into it.
Burnhard
Burnhard
I'm not wrong. You just need to read the blogs of the actual people who develop these things and then you will know why intellisense and C++ don't work too well together.

http://blogs.msdn.com/b/vcblog/archive/2007/12/18/intellisense-history-part-1.aspx

http://blogs.msdn.com/b/vcblog/archive/2008/02/29/intellisense-part-2-the-future.aspx

Edit:

I don't think you have conditional compilation macros and header files in C# and that fundamentally changes the accuracy of intellisense parsing.
phresnel
phresnel
Quote:
Original post by Burnhard
I'm not wrong. You just need to read the blogs of the actual people who develop these things and then you will know why intellisense and C++ don't work too well together.


Sorry, but no, you ain't not wrong. I just have to use my brain to see that retrieving meta-information about code is not possible without bringing code, which is essentially an array of characters, into some computer readable form. Source code appears to the compiler as does a binary blob to you; it has to be structured thereon.

The term "compiler" is quite generic, and whether it spits out abstract syntax trees, bytecode, assembly code, or reflectable CLR code or fancy class diagrams is irrelevant to the fact that it has to be compiled into some interpretable appearance.


Quote:
Edit:

I don't think you have conditional compilation macros [in C#]

Yes, you have.

Quote:
and header files in C#

Indeed, though gcc and msvc both have precompiled headers, and at least gcc has special code to detect header guards. Also, it is quite cheap to detect '#' that follow a newline and zero or more whitespaces.

Quote:
and that fundamentally changes the accuracy of intellisense parsing.


Macros are cheap in themselves. Templates, name lookup and the necessity for keeping information about context, and especially the combination of those three, are not.
Burnhard
Burnhard
My guess is you didn't read the explanations of the MS team on this. If you did, you wouldn't be busy contradicting them. Unless of course you're much more knowledgeable than they are on this particular subject.

Also, C# does not have a pre-processor, so parsing is totally different.
phresnel
phresnel
Quote:
Original post by Burnhard
My guess is you didn't read the explanations of the MS team on this.

Okay, I've read them. Now I know that you haven't read && understood them yourself, because it also explains some of the reasons why parsing C++ is slow, yet you start guessing that it is because of conditional compilation, but which is only a subset of the mix.

They even give hints on that code has to be compiled (click your own links, do an incremental search for "pars"). Compiling is not always outputting objects files. It is sometimes also generating help files or just an intellisense drop down box.

I think what you are really defending is that they don't use a fully fledged C++ compiler, which I never pretended, which you never stated.


Quote:
If you did, you wouldn't be busy contradicting them.

But I contradict you, not them.


Quote:
Also, C# does not have a pre-processor, so parsing is totally different.

But you talked about conditional compilation,
Quote:
I don't think you have conditional compilation macros and header files in C# and that fundamentally changes the accuracy of intellisense parsing.

. You have not been talking about a preprocessor. And C# has by definition preprocessor directives, even if not necessarily a seperate preprocessor: C# Preprocessor Directives.
Burnhard
Burnhard
C# does, but you can't build macros with them, so they don't have a huge effect on source files in a deeply nested structure many layers of includes away.

To be honest I'm not really sure what your point is. I'm saying that C++ is hard to parse out for intellisense and that point seems to be verified empirically by the generally ****-poor implementations of it we've seen in VS 6.0, 2003, 2005 and 2008. 2010 is much better, but still not as good as its CLR equivalents. Without reference to gurus, that at least gives me a hint that it's not as easy to get it right as you seem to imply.
phresnel
phresnel
Quote:
Original post by Burnhard
C# does, but you can't build macros with them, so they don't have a huge effect on source files in a deeply nested structure many layers of includes away.

The amount of macros used in good C++ code is negligible. And thus, they don't participate relevantly in compilation time.

But again, you weren't talking about macros, but conditional compilation. So let's stop that micro excursus.

Quote:
To be honest I'm not really sure what your point is.

The point is that you pretended, after some contextual inlining, that C# does not have to be compiled to reap meta information from it, which is wrong. Period.


Quote:
as you seem to imply.

Not sure where I did that.

Tbh, I am unsure why you constantly change your intentions and consensus from post to post, and counter derive untrue things afterhand about non existent posts, like me implying things about what you've said but which you did not say in reality. Get some sleep and stop becoming personal.
Telastyn
Telastyn
Umm, I'm fairly certain C# doesn't need to do any more compilation to do intellisense. Already compiled assemblies contain the metadata sitting there in a nice consumable form. C++ gets to grab headers and parse through them.

I don't think anyone would call extracting metadata from a C# assembly 'compiling'. There still needs to be some partial compilation for the newly written code, but that is far less than C++, and perhaps where the confusion/miscommunication is coming from.
Dalek_Supreme
Dalek_Supreme
Sorry, I did not reply earlier (my internet had some problems). Anyways, thanks for all of your replies, I appreciate your time, and you guys really helped me. I actually got more than I was looking for :D

One day, I will understand what Burnhard and phresnel are talking about. In the meantime, I'm learning about destructors :P. In the meantime, I'll be reading those links on Intellisense :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.