finding redeclaration

Hi

I am including several include directories in my visual studio project. However, when compiling I run into:
error C2995: 'void myfunction(T &)' : function template has already been defined
see declaration of 'myfunction'


In Visual studio, what is the easiest way to find the duplicate declarations? These are third party include dirs, so not code that i am familiar with. Also, is there a way to fix this in the file it is complaining in and move on? But in a way that should someone else want to include this third party file in their project, it does not break because of changes we make in it.

thanks
LuckyLucksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ess KayEntrapenuerCommented:
Do a Control+F
on entire solution for

 myfunction




(This is the first declaration)
To find declaration used, find an instance of the 'myfunction'
Hit F12, or right click and select Go To Declaration

Note the file, and line where it is declared.

--This is how you find the other (duplicate ) declarations
Hit Shift+F12  to show all references to that function
Show Ref

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
phoffric\Commented:
In every header file, be sure to include guards around them.
For example, if your header file is named myheaderfile.hpp, then it should look like:
#ifndef MYHEADERFILE_HPP
#define MYHEADERFILE_HPP

// all you header stuff including templates

#endif // MYHEADERFILE_HPP

Open in new window

phoffric\Commented:
If a third party header file does not include a guard, then this may work:
#ifndef MYHEADERFILE_HPP
#define MYHEADERFILE_HPP

#include "theirheaderfile.hpp"

#endif // MYHEADERFILE_HPP

Open in new window

Then you include myheaderfile.hpp into your code rather than theirheaderfile.hpp. But if the basic problem is due to a hierarchy of their header files, then a careful dependency analysis of their header files calling their other header files may be required, so that you know the exact ordering in which you must include your header files.

Once you determine the proper ordering, then you can create your own header file that includes all their header files in the right order, and then you might be able to just include your new ordered header file. If this latter approach works, then the problem was due to poor design of the third party header files.
Subrat (C++ windows/Linux)Software EngineerCommented:
You can also use
#pragma once
in Visual studio.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.