Solved

error: "template function has already been defined"

Posted on 1998-04-04
3
911 Views
Last Modified: 2008-02-01
Hi there,

This is probably a very easy question, but I'm a little confused over it.  I've been living in the land of Delphi for the past 4 years and have let my C++ experience slip.  I'm just now getting back into this area and hit a wall.  I'm not sure if this problem is compiler specific or a mis-understanding of C++ on my part.

I recently got a library and am trying to use it under MSVC++ 5.0.  The company I got it from says that it is supposed to work fine in this environment.  But whenever I try to compile it, I get an error (in a lot of different places) that says "template function has already been defined".  It proceeds to tell me which one is duplicated.

Is there some sort of setting in MSVC that allows me to work with these object templates?  

Thanks,
joe
0
Comment
Question by:greendot
3 Comments
 
LVL 5

Expert Comment

by:yonat
ID: 1184055
Sounds like you're including the same header twice (and therefore the function definition is repeated). If this is the case, just add include guards (in VC5 you can use "#pragma once" for that). Otherwise, please post the offending code.
0
 

Expert Comment

by:jann
ID: 1184056
Also check the library you used, does it use MFC library also?  If it does, it should use the shared MFC library.
0
 

Accepted Solution

by:
greendot2 earned 50 total points
ID: 1184057
I dug the "service release 3" out of my MSDN CD stack and now things are working fine.  Too bad I never saw that before.

greendot
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now