I'm just starting off with C++, setting up an environment in Visual Studio 2019. As I got used to coding in C# with intellisense, I thought it'd work the same way with C++, however it seems to be broken for me.
as you can see, it doesn't provide detailed information about methods (or anything at all) like it does with C#. In fact, it doesn't even display all of the overloads.
I don't even know if it's supposed to be like that or if its a problem on my end...
as you can see, it doesn't provide detailed information about methods
It doesn't appear to be broken, c++ intellisense with Visual Studio just doesn't offer the documentation style descriptions that C# may. Though you can provide you own descriptions for methods by adding a comment just before their declaration and it should appear where you want in intellisense.
(or anything at all)
c++ intellisense does give all of the method names and method declarations for the class, which isn't nothing and can be useful when you know generally what kind of method you need but don't know the specific method name, ( ex. .size() vs .count() vs .length() ) but I understand your frustration as I went from C# to c++ myself with Visual Studio
In fact, it doesn't even display all of the overloads.
All you need to do to display overloads should be to type the first parenthesis as if you were calling the method and it should display the overloads.
Related
I've always loved IntelliSense in C# in Visual Studio 2013. I'm not only talking about autocomplete function but also about those methods' descriptions (documentation's excerpts I suppose) viewed in autocomplete box. For example when I write:
List<int> l = new List<int>();
l.Add
Then I get a nice explanation:
Adds an object to the end of the System.Collections.Generic.List.
Also hints when calling some method are very useful (how many overloads, types of parameters).
But lately I decided to write some C++ code in Visual Studio 2013 and I see that those methods' descriptions are not visible. For example when I write:
string s;
s.length
all I get is autocomplete + function definition (return type and types of parameters). No information about what does this function do whatsoever. It's not something I can't live with. I know what .length() does :-) but collections in STL have many functions and it would be very very nice to have their descriptions (I know they can't replace whole documentation, but some comment on applications would be very nice) in Visual Studio, not only on www.cplusplus.com/reference/
So my question is this: is it possible in Microsoft Visual Studio to make IntelliSense work with C++ exactly as it works with C#?
Unfortunately, I have never seen any code hinting tool which works with C++ with as much detail as IntelliSense works with C#. There certainly are tools which can provide you with basic code hinting for std:: elements, but nowhere as detailed. Ive used codelite 2.0 in the past and its ok, but thats an entire IDE and provides basic code completion, probably the same as using VS2013
You could add extensive comments to the std header files MSVC ships with.
In my experience comments directly beside a method show up.
This would be a big project, and ideally you'd want to fold it back to MSVC sources and then to their sources so it would persist between versions.
I'd like to display function parameter information in a less verbose way than I see by default in Visual Studio. Are there any settings or methods for viewing these in a way that toggles or omits the details of the types and displays nearly just the names of the parameters?
For example, I might find something like this.
Would it be possible to see instead to only output the final type defs; something like this?
iterator insert(iterator hint, value_type &_Val)
That would be a real big deal for figuring out complex functions at a glance, without looking online, and it seems simple enough. Does this exist in visual studio?
No. You are seeing Intellisense results. It doesn't know the abstract signatures, it's based on the actual internal implementations of the Standard Library. It's indeed not helpful at all, but it was easy to implement for Microsoft. Also, since it's based on the actual header implementation, it's never out of sync.
While debugging i press F11 often to step into a function. For this project i use properties everwhere which is simply a RAII wrapper that checks if i have set the variable and gives me an assert if i have not. Its been useful.
However now debugging is annoying since F11 will step into the property. Can i skip it somehow? by writing attributes, keywords or anything?
I am using VS11beta
This is quite easy to set up when you're dealing with managed code. You can manually mark the function with the DebuggerHiddenAttribute class, and even turn on built-in debugger settings like "Step over properties and operators".
Unfortunately, automatically stepping over a particular function is not supported by Visual Studio for native C++ code. (At least, it wasn't supported up until VS 2010—I haven't had enough time to play with VS 11 to see if this is something they gave us to make up for the fact that they stole all our colors.)
There is a workaround, though, documented a long while ago on Andy Pennell's blog:
How to Not Step Into Functions using the Visual C++ Debugger
Essentially, you edit the following registry key (for VS 2010):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\NativeDE\StepOver
or for 64-bit applications:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\NativeDE\StepOver
to specify a regular expression that will be matched against functions by the debugger.
For example, if you don't want the debugger to step into overloaded operators, you can use the following expression:
\scope:operator\oper:=NoStepInto
As the disclaimer in the blog post says:
This is not a documented feature. Well obviously you are reading this “documentation” right here, but what I mean is that is not guaranteed to work as it was never officially tested, not is it supported by Microsoft. Its existence in future versions or update to current versions is not guaranteed.
Visual C++ does not highlight userTypes by default like; vector or MyCustomType; I've gotten used to this in C# and am wondering is there some way to get it to highlight userTypes for c++. I have checked in the fonts and color settings; User Types is set to a color but it has no affect in the editor.
No, there is no way to do this in Visual Studio 2010.
The reason is probably because C++ is notoriously hard to parse and determining what tokens are class names would require a lot of processing. This was probably deemed impractical because it would be too slow, though I can only guess.
This absolutely CAN be done!
I do it all of the time with my C++ types because I have my own typedefs for any type which is not strictly defined (pretty much all of them). Defining my own types prevents future incompatibilities (or at least mitigates them), as well as helps with portability. However, it requires an extra step before the types are highlighted properly.
Simply create a plain text usertypes.dat file in the same directory as devenv.exe using a standard text editor.
Put one type name on each line.
Then restart the IDE.
There is also a tool that manages this if you have complex needs that can be found at:
http://msmvps.com/blogs/p3net/archive/2010/06/27/updateusertype-visual-studio-addin.aspx
I used to use Visual Assist X for highlighting and intellisense while coding C++ projects that use a lot of templates.. This used to help me quite a bit.
http://www.wholetomato.com/downloads/
You could give it a try. But I must say it relatively reduces the speed of VS. Install the free trial and if you don't like it you can always remove it..!
I just want to see my own datatypes/functions/function parameters with a different color.
I have used Visual Assist X before, but it stopped working for some unknown reason. It doesn't color the custom functions or function parameters every time. Also, my trial time is over soon, and I am not going to buy something that doesn't work properly or whose most features I don't even use.
So, if there's any free syntax highlighting that colors all functions, etc. for Visual Studio 2008, that's what I'm looking for.
You can create a file(usertype.dat) containing any names, these will be colored differently.
You can read more about that here
Unfortunately you can't give your different types different colors from there but at least you can get your own types colored.
To color your own data structures, functions and parameters, a highlighter should know that they are your own data structures, functions and parameters. It means it should be able to parse C++ code. But, C++ code parsing is extremely hard task, so no one will do that just to highlight a couple of words. So, this may be just an associated feature of some powerful tool that definitely costs money.
Actually, it seems there are just some problems with your environment. I use Visual Assist X with Visual Studio 2003, 2005 and 2008 and it works like a charm!
I'd recommend proceeding with Visual Assist X if you are serious about MS VC++ programming. Actually, it is a must have tool as, say, ReSharper for CSharpers.
If you have the option to use Visual Studio 2010, there is Highlighterr, which changes the colors of classes, structs, macros and typedefs. There doesn’t appear to be a version for Visual Studio 2008, but what are you waiting for? ;-) C++0X awaits…