views:

124

answers:

3

This has always bugged me with C and C++:

In my header file I have something like:

bool UpdateWindow( int w, int h, char bpp, bool force, char* someOtherLongStuff )

Now, if I want to change that for whatever reason, I have to do so in both header and source file - that's annoying in my opinion.

Is there a way to automate this?

I'm using Visual Studio 2010

A: 

Not with the standard visual studio. I think you need a refactoring tool like Resharper, but I am not sure it will work for C++. Refactoring for C++ is a very though problem. My best shot would be to just follow the declaration with ctrl+click on the name and change in both sides.

fabrizioM
ReSharper doesn't support C++.
delnan
+2  A: 

I don't know of a shortcut for this, but even if one exists it might not give you as much of a saving as you imagine. If you are changing the header file then there are probably a lot of other places that will be affected by the change (the method body, other application code that includes this header, your client's code if you ship it as a library, unit tests, etc.) so having to change it in two places is just the tip of the iceberg.

Mark Byers
+2  A: 

I think I got it running with Visual Assist from Wholetomato. It's commercial but you could give it a try...

C++ was a long time ago - at least for me :)

TottiW
Visual Assist definitely automates this. It also allows you to create a definition from the declaration (and vice versa I think) which is very handy.
Alex - Aotea Studios