How to make definitions in Function declaring pop-ups?

Started by
8 comments, last by tom_mai78101 13 years, 6 months ago
Maybe the title is really misleading, but I did my best.

Here's a picture of me declaring a function and making that function:



Notice that the parameter names of the functions are different.

And when I create a new function (either erasing the previous, or make a new one):



The problem is the "x" and "y[]" not the same as the parameter names at the top (The NumberToDivide and TheArrayToPlace[], respectively). I have seen some functions in some source codes that were able to do so, and telling the developers what these commands are for. It's very impressive. So, how do I make the parameter names the name, even if i declare an X or Y or any short variables in the function header?

Thanks in advance.
Advertisement
The compiler doesn't really care about the names unless you actually use them, since all it needs are the types. This means you can completely omit names of unused parameters:
void Euclidean(int, int[]);void Euclidean(int x, int y[]){   return;}
I imagine that Intellisense is just choosing the last thing it sees, hence why the latter parameter names show up instead of the former. Omitting the names from the declaration would probably give you back some control with regard to what pops up, but I'm not a huge fan of doing that sort of thing because it makes your header files a lot less self-documenting.
As I am sure you are aware the parameter names in function prototypes play no part in the declaration and I guess the parser is ignoring them like it should and instead using the names in the function definitions. I do not even know which text editor you are using so if the edit supports using prototype names is doubtful at best.
"You insulted me!" I did not say that in the private message Tom Sloper!
I'm using Visual Studio 2010. The language I'm using is C/C++.

SO, it all comes down to, declaring a function at the top, copy/paste the declaration to the bottom, then make two large brackets "{}", then just type the way it is supposed to be?

I thought we could use something like, _typedef, or define, or something that we can override the parameter names, and give it some meaning to them.
When you write a function call, intellisense pops up with a list of overloads and the parameters for each. It goes off the names you gave variables in the function declaration (header), as most of the time the actual source is buried in some other translation unit, and it's impractical for intellisense to go digging this up in real time.

But in your case the function is defined in the same file you're using it, and for some reason intellisense is giving priority to the parameter names in the definition (source). Intellisense is sometimes laggy or unreliable. Sometimes it gets things wrong entirely, or bugs out and refuses to work in certain source files. In your case it's probably working as intended though. Try recompiling and see what happens.
The problem still persisted, even after compiling, building, and searching for results (came up dry).

Did anyone ever had problems like this? I would to know how they troubleshoot this, even if IntelliSense doesn't work the way they (developers) wanted, even if it's intended to do so.
You can try deleting the intellisense database for your project. It's in your project's root folder and is called <YourProject>.ncb
After deleting the NCB file in my project root folder, I still get this "unintended" effect in IntelliSense.

Here's what I found:



This is a function I wrote, and had commented out the bottom function. I had declare this function at the top.

After that, I erased the comment lines (removing the double dashes), I still get this:



I'm sure there's something wrong about this.
I think that's just how Visual Studio's Intellisense handles ambiguous situations, I don't think there's much you can do about it.

It will include comments in the member list, perhaps that helps?

Quote:Original post by Wan
I think that's just how Visual Studio's Intellisense handles ambiguous situations, I don't think there's much you can do about it.

It will include comments in the member list, perhaps that helps?


Thanks for this new info. Guess I should modify my style a little bit to accommodate the comment description for IntelliSense.

Thank you, everyone.

This topic is closed to new replies.

Advertisement